How can I store values of a registration form which are going to Janrain database through Janrain capture authentication in my local postgresql database. My application is in RoR.
1 Answers
Firstly, you shouldn't need to store registration form data in your own database. That would be redundant when using Janrain Registration.
Once the user is authenticated and the Janrain OAuth token has been sent to the Registration widget you can use that token to call the entity endpoint:
https://SOME_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken
This will return the authenticated user's profile data in json format. You can filter out fields using the attributes parameter as documented here: https://docs.janrain.com/api/registration/entity/
https://SOME_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken&attributes='["uuid","familyName","givenName"]'
You should probably bind to the Janrain Registrations Javascript event handler: "onCaptureCreateSession" which when fired will contain the access token. You can then send that token to your server where it can make the entity api call and then store any relevant data in your server (if necessary).
janrain.events.onCaptureSessionCreated.addHandler(function(result) {
//make an ajax call to your server here with the token:
var token = result.accessToken
});
If you absolutely must get form field data before the form is submitted you could bind to the form's onSubmit event and simply retrieve the field data from the form before it is submitted. This should be achievable using plain Javascript or most mainstream libraries.
Here's an example that should get you started:
janrain.events.onCaptureRenderComplete.addHandler(function(result) {
if (result.renderingBuiltInScreen == false) {
//NOTE: screen names can be configuration dependent.
if(result.screen == "traditionalRegistration" || result.screen == "socialRegistration"){
//bind to rendered form here and do stuff
//form names and field names are configuration dependent.
}
}
}

- 374
- 2
- 4
-
When I am hitting https://MY_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken in my browser, I can see data in JSON format but when I am doing same thing in my controller I am only getting url. My controller code is: `class UsersController < ApplicationController require 'rest_client' def index @results = @ab @url def getData response = RestClient::Resource.new(@url,{ :content_type => :json, "secret" => "myapikey" } end def retrieve_results @id = params[:id] @url = "https://myapp.janraincapture.com/entity?access_token=#{@id}" @ab = JSON.parse(getData) end` – Mayuresh Srivastava Oct 14 '16 at 18:10
-
oh yeah I already up voted your answers but right now my reputation is < 15 :-( – Mayuresh Srivastava Oct 16 '16 at 17:44
-
Hey..need one more suggestion from you regarding updation.. If user is updating the profile data in janrain..then I want to update my local database also. So from your view how can I update data in my local db? – Mayuresh Srivastava Oct 18 '16 at 15:26
-
In case anyone else is wondering, you can "intercept" any Registration form using the method demonstrated above. You just need to know the Registration configuration (aka "flow") form name and the screen name that it is displayed upon. – PBICS Oct 19 '16 at 19:29