Socialid.login.loginConnection
Renato.neves (Talk | contribs) (→Description) |
Ivan.filho (Talk | contribs) (→Description) |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
== Description == | == 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. | |
− | <span style="color: red"> | + | In case of success, this API will also trigger the save behavior of [[socialid.connectionStorage]]. |
+ | |||
+ | <span style="color: red">Important:</span> see [[Social Login Tokens]] for detailed information about the tokens used by the Social Login and best security practices. | ||
== Usage == | == Usage == | ||
Line 17: | Line 19: | ||
{| | {| | ||
! align="left" width="200px" | connectionId | ! align="left" width="200px" | connectionId | ||
− | | width="200px" | | + | | width="200px" | required |
− | | | + | | User connection identifier. |
|+ | |+ | ||
! align="left" width="200px" | handler | ! align="left" width="200px" | handler | ||
− | | width="200px" | | + | | width="200px" | optional |
− | | | + | | Callback function to handle the API response. |
|} | |} | ||
Line 29: | Line 31: | ||
{| | {| | ||
! align="left" width="200px" | data | ! align="left" width="200px" | data | ||
− | | | + | | Always "null". This API does not return data. |
|+ | |+ | ||
! align="left" width="200px" | status | ! align="left" width="200px" | 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 == | == Example == | ||
− | + | Automatically logs an user given its connection_id: | |
var handler = function(response) { | var handler = function(response) { | ||
if (response.status == "success") { | if (response.status == "success") { | ||
− | alert(" | + | alert("You have been logged in successfully!"); |
} else { | } else { | ||
− | alert(" | + | alert("Connection not found. Generate a new connectionId."); |
} | } | ||
} | } | ||
Line 50: | Line 52: | ||
socialid.login.loginConnection(connectionId, handler); | socialid.login.loginConnection(connectionId, handler); | ||
− | + | You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground |
Latest revision as of 19:47, 11 November 2020
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.
In case of success, this API will also trigger the save behavior of socialid.connectionStorage.
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