Socialid.login.loginUserToken
(Difference between revisions)
Renato.neves (Talk | contribs) (→Example) |
Renato.neves (Talk | contribs) (→API Response) |
||
Line 36: | Line 36: | ||
|+ | |+ | ||
! align="left" width="200px" | status | ! align="left" width="200px" | status | ||
− | | The API response status. | + | | The API response status. Can be '''success''', if the user has been logged in successfully, or '''not_found''', if there is no valid combination of the given userId and userToken. |
|} | |} | ||
Revision as of 11:48, 4 November 2014
Contents |
Description
API to automatically log an user given its user_token.
The userId and userToken can be retrieved from the RESTful APIs GET login/info or GET login/users/:user_id.
A common use case for this API is when the user session (cookie) in the Social Login has been expired or erased and you want to log the user automatically given you already identified him before via traditional login, for example.
Important: see Social Login Tokens for detailed information about the tokens used by the Social Login and best security practices.
Usage
socialid.login.loginUserToken(userId, userToken, handler)
Parameters
userId | required | User identifier. | userToken | required | User token. | handler | optional | Callback function to handle the API response. |
---|
API Response
data | In case of success, it will be a Javascript object containing the connection_id generated for the user. | status | The API response status. Can be success, if the user has been logged in successfully, or not_found, if there is no valid combination of the given userId and userToken. |
---|
Example
Automatically logs an user given its user_id and user_token:
var handler = function(response) { if (response.status == "success") { alert("You have been logged in successfully!"); } else { alert("userId and userToken are invalid."); } } var appId = 1, userId = 34, userToken = '1234567890'; socialid.login.init(appId); socialid.login.loginUserToken(userId, userToken, handler);
Example of "data" object:
data = { connection_id: "3875294927582875" }
You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground