Socialid.login.loginConnection

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Description)
 
Line 7: Line 7:
 
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.
  
In case of success, this API will also trigger the save behavior of the '''connectionStorageType''' option for the given Connection ID value.
+
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.
 
<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.

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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox