Sample Code for Janrain integration for CFML / ColdFusion

Sample Code for Janrain integration for CFML / ColdFusion

Here is a sample code for integration the Janrain Engage social login. This is inspired by the sample codes published over at https://github.com/janrain/Janrain-Sample-Code. (I asked them to integrate the CFML sample code, but they did not reply) Alas, you find the code below or can also get it on Github as well at https://github.com/thenitai/ColdFusion-Janrain-Sample-Code.

[coldfusion]<!— This code sample shows how to make the auth_info API call using CFML —>

<!— Enter your API key here —>
<cfset variables.apikey = "">

<!— Step 1) Extract the token from your environment —>
<cfset variables.token = form.token>

<!—
Step 2) Now that we have the token, we need to make the api call to auth_info.
auth_info expects an HTTP Post with the following paramters:
—>

<cfhttp url="https://rpxnow.com/api/v2/auth_info"&gt;
<cfhttpparam name="token" value="#variables.token#" type="URL">
<cfhttpparam name="apiKey" value="#variables.apikey#" type="URL">
</cfhttp>

<!— If status code is 200 —>
<cfif cfhttp.responseheader.status_code EQ "200">

<!— Step 3) read the json response —>
<cfset variables.auth_info_json = Deserializejson(cfhttp.filecontent)>

<!— Set default variables which might be in the response (depending on the provider) —>
<cfparam name="variables.auth_info_json.profile.displayName" default="" />
<cfparam name="variables.auth_info_json.profile.email" default="" />
<cfparam name="variables.auth_info_json.profile.photo" default="" />

<!— Step 4) use the response to sign the user in —>
<cfif variables.auth_info_json.stat EQ "OK">
<!—
‘identifier’ is the unique idenfifier that you use to sign the user in to your site
—>
<cfset variables.identifier = variables.auth_info_json.profile.identifier>
<!—
get fields
—>
<cfset variables.displayName = variables.auth_info_json.profile.displayName>
<cfset variables.email = variables.auth_info_json.profile.email>
<cfset variables.profile_pic_url = variables.auth_info_json.profile.photo>
<cfset variables.providerName = variables.auth_info_json.profile.providerName>
<cfset variables.preferredUsername = variables.auth_info_json.profile.preferredUsername>
<!—
actually sign the user in. this implementation depends highly on your platform, and is up to you.
—>
<!— <cfinvoke component="" method=""></cfinvoke> —>

<!— Simply dump variables —>
<cfdump var="#variables#">

<!— Error with Authentication —>
<cfelse>
<h1>Error with the authentication</h1>
<cfdump var="#variables.auth_info_json.err.msg#">
</cfif>

<!— There is an error with the http response —>
<cfelse>
<h1>Error with the HTTP Response</h1>
<cfdump var="#cfhttp#">
</cfif>[/coldfusion]

Helpmonks All-in-one Customer Service Platform
Why Coldfusion / CFML has its place and is worth to learn it

I actually never indulge in conversations why one programming language is better then another, because what is right to you, does not automatically mean, it is right for someone else. So, for me ColdFusion, or as we call the language itself - CFML, works very well. Nevertheless, in this post…

Helpmonks All-in-one Customer Service Platform
OpenBD and MongoDB: Can't get easier then this

I'm currently working on a project that uses MongoDB (yes, that's the awesome NoSQL database everyone talks about). Now, my favorites language of choice (CFML) and especially my favorite open source CFML engine OpenBD, has support for MongoDB built in which makes it a snap to use for any ColdFusion…

Helpmonks All-in-one Customer Service Platform
CFML and Cannot run program "chmod": java.io.IOException: error=24, Too many open files

Migrating one of my customers the other day, bought up an ugly error when I had to create 2000 directories on one go. The error was: [code]Cannot run program "chmod": java.io.IOException: error=24, Too many open files[/code] While, "too many open files" usually means one can raise the limit of open…

Helpmonks All-in-one Customer Service Platform
Setting the correct Java version under MacOS X

My favorite scripting language is CFML, or as some know it as ColdFusion. I like it because it is very very powerful, easy to use and can do just about everything your xyz language can do. For many years, ColdFusion was a closed sourced system, where the former Macromedia and…

Helpmonks All-in-one Customer Service Platform
Coldfusion: How to pass struct and array in a URL

A user just asked: I need to pass my array to a webserver. But somehow, the array passed with cfhttp throws an error. Please help You can not pass a structure or an array in a URL as they are complex values and Coldfusion does not have a way to…

Helpmonks All-in-one Customer Service Platform
Razuna Digital Asset Management module for Drupal

Sometimes here at Razuna, we’re reminded of why we offer open source digital asset management to people around the world. And this week, was one of those wonderful occasions. We received an email from Mandar Harkare, who told us that he had developed a Dupal module for Razuna. He even…

Trusted by over 2,000 organizations with millions of emails

Helpmonks helps us answer customer emails at lighting speed
We couldn't do our job without Helpmonks!
Helpmonks, the best thing since sliced bread
Excellent option for collaborating email amongst your team
A good platform that is here to grow and help you grow
Helpmonks is a great tool that our company utilizes and depends on
Great shared inbox for the team
Fantastic email support service for any business
Easy to navigate and catalog data for specific users
Solid Helpdesk software w/ responsive customer support
A really good solution to manage customer support mailbox
Good support, useful features

One more thing...

Helpmonks gives you the ability tocollaborate as a groupin your shared mailbox, features aTeam To-Do App, powerfulCustomer Relationship Management (CRM)capabilities, a completeLive-Chat tool, a mighty Email Marketing Platform that includes sending ofemail campaignsandemail automation, collision detection, email tracking, reminders, mentions, custom fields, custom applications, customer satisfaction ratings, Single-Sign-On (SSO) & SAML authentication, Trello, Zapier, Slack, an API, and much more.

Check outthe complete feature listor sign up for afree 30-day shared inbox trial now