Socialid.login.loginConnection

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Description)
(Description)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Description ==
 
== Description ==
  
Chama a API para logar automaticamente um usuário dado seu connection_id.
+
API to automatically log an user given its connection_id.
  
Um nova conexão pode ser criada a partir de um user_id usando a API REST [[POST login/apps/:app_id/sign_ins]]. Também é possível criar novas conexões a partir das credenciais de alguma rede social do usuário. Veja as [[Social Login APIs|APIs do Social Login]].
+
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]].
 +
 
 +
<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 13: Line 19:
 
{|
 
{|
 
! align="left" width="200px" | connectionId
 
! align="left" width="200px" | connectionId
| width="200px" | obrigatório
+
| width="200px" | required
| Identificador da conexão do usuário.
+
| User connection identifier.
 
|+
 
|+
 
! align="left" width="200px" | handler
 
! align="left" width="200px" | handler
| width="200px" | opcional
+
| width="200px" | optional
| Especifica uma função de callback para tratar a resposta da API.
+
| Callback function to handle the API response.
 
|}
 
|}
  
Line 25: Line 31:
 
{|
 
{|
 
! align="left" width="200px" | data
 
! align="left" width="200px" | data
| Sempre "null". Esta API não retorna dados.
+
| Always "null". This API does not return data.
 
|+
 
|+
 
! align="left" width="200px" | status
 
! align="left" width="200px" | status
| O status da execução da chamada da API. Pode ser "success", se o usuário foi logado com sucesso, ou "not_found", caso não exista a conexão especificada por connectionId.
+
| 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 ==
  
Loga um usuário na sessão atual dado seu connection_id:
+
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("Usuário logado com sucesso");
+
         alert("You have been logged in successfully!");
 
     } else {
 
     } else {
         alert("Conexão inexistente. Tente outro connectionId.");
+
         alert("Connection not found. Generate a new connectionId.");
 
     }
 
     }
 
   }
 
   }
Line 46: Line 52:
 
   socialid.login.loginConnection(connectionId, handler);
 
   socialid.login.loginConnection(connectionId, handler);
  
Teste as APIs em nosso playground: https://sid-examples.herokuapp.com/social_logins/playground
+
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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox