Socialid.login.loginUserToken

(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 userId e userToken.
+
API to automatically log an user given its user_token.
  
O userId e userToken podem ser obtidos a partir da API [[GET login/info]] ou [[GET login/users/:user_id]].
+
The userId and userToken can be retrieved from the RESTful APIs [[GET login/info]] or [[GET login/users/:user_id]].
  
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" | userId
 
! align="left" width="200px" | userId
| width="200px" | obrigatório
+
| width="200px" | required
| Id do usuário.
+
| User identifier.
 
|+
 
|+
 
! align="left" width="200px" | userToken
 
! align="left" width="200px" | userToken
| width="200px" | obrigatório
+
| width="200px" | required
| Token do usuário.
+
| User token.
 
|+
 
|+
 
! 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 33: Line 33:
 
{|
 
{|
 
! align="left" width="200px" | data
 
! align="left" width="200px" | data
| Em caso de sucesso, será um objeto contendo o connection_id gerado para o usuário.
+
| In case of success, it will be a Javascript object containing the connection_id generated for the user.
 
|+
 
|+
 
! 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 combinação user_id e user_token para o Social Login.
+
| The API response status. It could be "success", if the user has been logged in successfully, or "not_found", if there is no valid combination of the given user_id and user_token.
 
|}
 
|}
  
 
== Example ==
 
== Example ==
  
Loga um usuário na sessão atual dado seu user_id e user_token:
+
Automatically logs an user given its user_id and user_token:
  
 
   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("User_id e user_token não conferem.");
+
         alert("User_id and user_token are invalid.");
 
     }
 
     }
 
   }
 
   }
Line 54: Line 54:
 
   socialid.login.loginUserToken(userId, userToken, handler);
 
   socialid.login.loginUserToken(userId, userToken, handler);
  
Exemplo de dados no objeto "data":
+
Example of "data" object:
  
 
   data = {
 
   data = {
Line 60: Line 60:
 
   }
 
   }
  
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:54, 3 November 2014

Contents

Description

API to automatically log an user given its user_token.

The userId and userToken can be retrieved from the RESTful APIs GET login/info or GET login/users/:user_id.

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.loginUserToken(userId, userToken, handler)

Parameters

userId required User identifier.
userToken required User token.
handler optional Callback function to handle the API response.

API Response

data In case of success, it will be a Javascript object containing the connection_id generated for the user.
status The API response status. It could be "success", if the user has been logged in successfully, or "not_found", if there is no valid combination of the given user_id and user_token.

Example

Automatically logs an user given its user_id and user_token:

 var handler = function(response) {
    if (response.status == "success") {
       alert("You have been logged in successfully!");
    } else {
       alert("User_id and user_token are invalid.");
    }
 }
 var appId = 1, userId = 34, userToken = '1234567890';
 socialid.login.init(appId);
 socialid.login.loginUserToken(userId, userToken, handler);

Example of "data" object:

 data = {
   connection_id: "3875294927582875"
 }

You can test this parameters in our playground: https://sid-examples.herokuapp.com/social_logins/playground

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox