如何在 Rails 中从 Janrain 获取用户配置文件数据
How do I get User Profile Data from Janrain in Rails
如何在本地 postgresql 数据库中存储通过 Janrain 捕获身份验证进入 Janrain 数据库的注册表单的值。我的申请在 RoR 中。
首先,您不需要将注册表单数据存储在您自己的数据库中。使用 Janrain 注册时,这将是多余的。
一旦用户通过身份验证并且 Janrain OAuth 令牌已发送到注册小部件,您就可以使用该令牌调用实体端点:
https://SOME_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken
这将 return 已验证用户的个人资料数据采用 json 格式。您可以使用此处记录的属性参数过滤掉字段:https://docs.janrain.com/api/registration/entity/
https://SOME_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken&attributes='["uuid","familyName","givenName"]'
您可能应该绑定到 Janrain Registrations Javascript 事件处理程序:"onCaptureCreateSession" 触发时将包含访问令牌。然后您可以将该令牌发送到您的服务器,在那里它可以进行实体 api 调用,然后将任何相关数据存储在您的服务器中(如有必要)。
janrain.events.onCaptureSessionCreated.addHandler(function(result) {
//make an ajax call to your server here with the token:
var token = result.accessToken
});
如果您绝对必须在提交表单之前获取表单字段数据,您可以绑定到表单的 onSubmit 事件,并在提交之前从表单中检索字段数据。这应该可以使用普通 Javascript 或大多数主流库来实现。
这是一个可以帮助您入门的示例:
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.
}
}
}
如何在本地 postgresql 数据库中存储通过 Janrain 捕获身份验证进入 Janrain 数据库的注册表单的值。我的申请在 RoR 中。
首先,您不需要将注册表单数据存储在您自己的数据库中。使用 Janrain 注册时,这将是多余的。
一旦用户通过身份验证并且 Janrain OAuth 令牌已发送到注册小部件,您就可以使用该令牌调用实体端点:
https://SOME_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken
这将 return 已验证用户的个人资料数据采用 json 格式。您可以使用此处记录的属性参数过滤掉字段:https://docs.janrain.com/api/registration/entity/
https://SOME_APP_NAME.janraincapture.com/entity?access_token=someaccesstoken&attributes='["uuid","familyName","givenName"]'
您可能应该绑定到 Janrain Registrations Javascript 事件处理程序:"onCaptureCreateSession" 触发时将包含访问令牌。然后您可以将该令牌发送到您的服务器,在那里它可以进行实体 api 调用,然后将任何相关数据存储在您的服务器中(如有必要)。
janrain.events.onCaptureSessionCreated.addHandler(function(result) {
//make an ajax call to your server here with the token:
var token = result.accessToken
});
如果您绝对必须在提交表单之前获取表单字段数据,您可以绑定到表单的 onSubmit 事件,并在提交之前从表单中检索字段数据。这应该可以使用普通 Javascript 或大多数主流库来实现。
这是一个可以帮助您入门的示例:
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.
}
}
}