Socialid.login.loginConnection

(Difference between revisions)
Jump to: navigation, search
(Description)
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.
  
O connection_id pode ser obtido a partir da API [[GET login/info]]. Também é possível criar uma nova conexão a partir de um user_id, usando a API [[POST login/apps/:app_id/sign_ins]], ou 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|APIs do Social Login]].
  
Um caso de uso desta API é para quando a sessão (cookie) do usuário no Social Login tenha expirado ou sido apagada e se queira logar automaticamente um usuário já identificado (via login tradicional ou outro meio).  
+
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">Importante:</span> veja a página de [[Social Login Tokens|tokens do Social Login]] para maiores informações sobre os tokens usados no Social Login e boas práticas de segurança.
+
<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 17:
 
{|
 
{|
 
! 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 29: Line 29:
 
{|
 
{|
 
! 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. It could 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. Gere outro connectionId.");
+
         alert("Connection not found. Generate a new connectionId.");
 
     }
 
     }
 
   }
 
   }
Line 50: Line 50:
 
   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

Revision as of 18:38, 3 November 2014

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 APIs do Social Login.

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. It could 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