Socialid.login.loginConnection
Renato.neves (Talk | contribs) (→API Response) |
(→Description) |
||
Line 3: | Line 3: | ||
API to automatically log an user given its connection_id. | API to automatically log an user given its connection_id. | ||
− | The connection_id can be retrieved from the RESTful API [[GET login/info]]. It's also possible to create a new connection given an user_id, using the RESTful API [[POST login/apps/:app_id/sign_ins]], or given the credentials from any user's social network. See [[Social Login APIs | + | The connection_id can be retrieved from the RESTful API [[GET login/info]]. It's also possible to create a new connection given an user_id, using the RESTful API [[POST login/apps/:app_id/sign_ins]], or given the credentials from any user's social network. See [[Social Login APIs]]. |
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. | 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. |
Revision as of 14:14, 22 December 2016
Contents |
Description
API to automatically log an user given its connection_id.
The connection_id can be retrieved from the RESTful API GET login/info. It's also possible to create a new connection given an user_id, using the RESTful API POST login/apps/:app_id/sign_ins, or given the credentials from any user's social network. See Social Login APIs.
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.loginConnection(connectionId, handler)
Parameters
connectionId | required | User connection identifier. | handler | optional | Callback function to handle the API response. |
---|
API Response
data | Always "null". This API does not return data. | status | The API response status. Can be success, if the user has been logged in successfully, or not_found, if there is no connection available with the given connectionId. |
---|
Example
Automatically logs an user given its connection_id:
var handler = function(response) { if (response.status == "success") { alert("You have been logged in successfully!"); } else { alert("Connection not found. Generate a new connectionId."); } } var appId = 1, connectionId = '1234567890'; socialid.login.init(appId); socialid.login.loginConnection(connectionId, handler);
You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground