Social Login User Guide

(Difference between revisions)
Jump to: navigation, search
(Sessão do usuário no Social Login)
Line 1: Line 1:
== Introdução ==
+
== Introduction ==
  
Social Login permite que usuários se loguem em websites ou aplicações usando suas contas do Facebook, Twitter, LinkedIn ou outras redes. Isso aumenta o engajamento e taxas de conversão pois oferece um simples processo de cadastro, uma vez que o usuário começa a interagir com o website com apenas 1 clique ao invés de preencher complexos formulários de cadastro. A maioria dos usuários já estão acostumados com suas redes sociais no dia-a-dia e preferem usar logins sociais no lugar do tradicional login com usuário e senha.
+
Social Login allow users to log in websites or application using their Facebook, Twitter, Linkedin, or Google+ accounts. This increases engagement and conversion rates by offering a simple registration mechanism where the user can start interacting with the website with just 1 click instead of forcing him or her to fill multiple fields on a registration form. Most people already use their social network accounts on a daily basis and would rather log in using these accounts than using a traditional email / password login.
  
 
[[File:Social login diagram.png|400px]]
 
[[File:Social login diagram.png|400px]]
  
A implementação do Social Login consiste em 3 etapas:
+
Social Login implementation is divided into 3 steps:
  
# Configurar uma instância do Social Login
+
# Configure a Social Login instance
# Instalar o widget no Website
+
# Install the widget on the Website
# Implementar o callback no Website
+
# Implement the callback on the Website
  
== Configuração do Social Login ==
+
== Social Login Configuration ==
  
 
[[File:Social login settings.png|500px]]
 
[[File:Social login settings.png|500px]]
  
A imagem acima mostra a tela de configuração do Social Login. Nesta tela deve-se configurar:
+
The picture above shows the Social Login configuration screen. On this screen you have to fill:
  
* Nome: um nome para a instância do Social Login usado apenas como referência interna.
+
* Name: a name for the Social Login instance (used as an internal reference only).
* Callback url: a url para a qual iremos postar o token de identificação do usuário que acabou de realizar login social no website.
+
* Callback url: the url that will receive a post request with the user identification token after a successful login attempt.
* Métodos de inscrição: as redes sociais disponíveis para o usuário realizar login social. É possível customizar as aplicações sociais para serem usadas aqui. Estas aplicações sociais podem ser configuradas nas próprias redes sociais para levar em consideração o branding da marca, como o nome e logo:
+
* Registration methods: the social networks that can be used to perform the Social Login. It is possible to change the social applications used here; these social applications can be configured on the social networks themselves to take in consideration branding, like name and logo:
  
 
[[File:Social id facebook app.png|500px]]
 
[[File:Social id facebook app.png|500px]]
  
A criação de aplicações sociais é realizada seguindo os passos de um wizard de configuração:
+
The creation of social applications is done following a configuration wizard:
  
 
[[File:Social app id secret.png|500px]]
 
[[File:Social app id secret.png|500px]]
  
== Instalação do Widget ==
+
== Widget Installation ==
  
A instalação do widget no website é realizada a partir da aplicação de um trecho de código em Javascript que carrega o widget no local configurado para ele aparecer. A tela que permite configurar o tema do widget e que fornece o trecho de código Javascript pode ser vista na seguinte imagem:
+
This installation is done by pasting a JavaScript code snippet that loads the Social Login widget in place. The screen that allows to configure the widget theme and that shows the JavaScript code snippet is shown in the following picture:
  
 
[[File:Social login widget code.png|300px]]
 
[[File:Social login widget code.png|300px]]
  
Ao se entrar na página configurada com o código Javascript, o seguinte widget deve ser visualizado, se configurado com o tema “bricks”:
+
When entering a page configured with the JavaScript code, the following widget should be seen (if configured with the "bricks" theme):
  
 
[[File:Social login widget bricks.png|200px]]
 
[[File:Social login widget bricks.png|200px]]
  
Ou se configurado com o tema “icons”:
+
Or if you use the "icons" theme:
  
 
[[File:Social login widget icons.png|150px]]
 
[[File:Social login widget icons.png|150px]]
  
== Implementação do Callback ==
+
== Callback Implementation ==
  
Nesta etapa é implementada a integração do social login com o gerenciamento de usuários já existente no website. Fornecemos APIs que permitem esta integração de uma forma bastante simples. A idéia basicamente é relacionar o “id” do usuário no social login com o “id” do usuário no website. Dois casos podem acontecer:
+
This step is used to integrate social login with the user management system already in place on the website. We have APIs that allow this integration in a very simple way. The basic idea is to associate the user's "id" on social login and the user's "id" on your website. Two things can happen:
  
1. No callback, o “id” do usuário no social login não está relacionado com nenhum usuário do website: neste caso, este é um login social novo, então deve-se criar um usuário no website e relacioná-lo com o usuário do social login, ou, caso já exista um usuário logado no website (via login tradicional, por exemplo), basta relacioná-lo com o usuário do social login.
+
1. On the callback, the user's "id" is not related with any website user: in this case, a new user should be created (on the website) and associated with the social login user. If a user already exists (say, if the user created a traditional account), the user's account should be associated with the social login account.
  
2. No callback, o “id” do usuário no social login já está relacionado a um usuário do website: neste caso basta logar o usuário na sessão do website.
+
2. On the callback, the user's "id" is already associated with a website user: in this case, the user should be logged in.
  
Para se obter o “id” do usuário no social login na url de callback basta seguir os passos explicados na tela de “Chamar a API” do produto:
+
To get the user's "id" from Social Login, follow the steps explained on the "Call the API" screen:
  
 
[[File:Social login call api.png|500px]]
 
[[File:Social login call api.png|500px]]
  
=== Passo 1: Extraia o parâmetro token dos dados do POST ===
+
=== Step 1: Extract the "token" parameter from POST data ===
  
Enviamos nos dados POST um parâmetro “token” que identifica o usuário que acabou de ser registrado na aplicação de Social Login implantada em seu site. Você precisa usar esse token para chamar nossa API e obter a informação de autenticação do usuário.
+
We send via POST a parameter called "token" that identifies the user that just registered / logged in on the Social Login used on your website. Use this token to call the API and get the user's authentication information.
  
=== Passo 2: Chame nossa API para obter informações de autenticação do usuário ===
+
=== Step 2: Call our API to get the user's authentication information ===
  
Use o token que você acabou de receber e sua API secret para chamar a API login/info. Retornaremos um JSON com as informações básicas do usuário e da autenticação usada por ele.
+
Use the token you just got and your API secret to call the login/info API. You'll get back a JSON data structure with basic information about the user and the authentication method used by him/her.
  
URL da API para chamar:
+
URL to call:
  
 
   GET https://api.socialidnow.com/v1/marketing/login/info?api_secret=<secret>&token=<token>
 
   GET https://api.socialidnow.com/v1/marketing/login/info?api_secret=<secret>&token=<token>
  
Parâmetros:
+
Parameters:
* api_secret: o secret fornecido na tela de “Chamar a API”
+
* api_secret: the "secret" you can get on the "Call the API" screen
* token: o token fornecido no passo 1
+
* token: the token returned on step 1
  
=== Passo 3: Extrair o id do usuário a partir da resposta do login/info ===
+
=== Step 3: Extract the user's "id" from the login/info response ===
  
Quando você chamar a API login/info você receberá uma resposta assim:
+
When you call the login/info API you'll get a response like this:
  
 
[[File:Api login info.png|500px]]
 
[[File:Api login info.png|500px]]
  
Você pode usar o campo "id" como a chave única para identificar o usuário em seu site. Este é o “id” do usuário no social login.
+
You can use the "id" field as a unique key to identify the user on your website. This is this user's "id" on Social Login.
  
== Sessão do usuário no Social Login ==
+
== Social Login user session ==
  
A API login/info fornece um dado importante: “connection_id”. Mantemos uma identificação da sessão de cada usuário logado no Social Login para usar em certas APIs e widgets, de forma a manter seguro o acesso a estes recursos.  
+
The login/info API returns another very important value: “connection_id”. We keep a session identification for every logged in user on Social Login to use in certain APIs and widgets (to make it easier to use these resources).  
  
No momento em que o usuário se loga usando o Social Login, gravamos um cookie de sessão no browser do usuário e rastreamos o "connection_id" de forma a identificá-lo automaticamente em widgets e APIs. Algumas APIs RESTful necessitam do "connection_id" de forma explícita, a qual pode se obtida pela API login/info.
+
At the moment the user logs in on Social Login, we store a session cookie on his browser and track the "connection_id" so we can identify him automatically on certain widgets and APIs. Some RESTful APIs require the "connection_id" value, and so it is returned by the login/info API.
  
É importante salientar que este “connection_id” muda a cada login social do usuário, portanto, só deve ser usado no contexto de uma sessão de login.
+
It's important to note that this "connection_id" value changes every time the user logs in, so it should only be used as a *session* identification method.

Revision as of 15:50, 3 November 2014

Contents

Introduction

Social Login allow users to log in websites or application using their Facebook, Twitter, Linkedin, or Google+ accounts. This increases engagement and conversion rates by offering a simple registration mechanism where the user can start interacting with the website with just 1 click instead of forcing him or her to fill multiple fields on a registration form. Most people already use their social network accounts on a daily basis and would rather log in using these accounts than using a traditional email / password login.

Social login diagram.png

Social Login implementation is divided into 3 steps:

  1. Configure a Social Login instance
  2. Install the widget on the Website
  3. Implement the callback on the Website

Social Login Configuration

Social login settings.png

The picture above shows the Social Login configuration screen. On this screen you have to fill:

  • Name: a name for the Social Login instance (used as an internal reference only).
  • Callback url: the url that will receive a post request with the user identification token after a successful login attempt.
  • Registration methods: the social networks that can be used to perform the Social Login. It is possible to change the social applications used here; these social applications can be configured on the social networks themselves to take in consideration branding, like name and logo:

Social id facebook app.png

The creation of social applications is done following a configuration wizard:

Social app id secret.png

Widget Installation

This installation is done by pasting a JavaScript code snippet that loads the Social Login widget in place. The screen that allows to configure the widget theme and that shows the JavaScript code snippet is shown in the following picture:

Social login widget code.png

When entering a page configured with the JavaScript code, the following widget should be seen (if configured with the "bricks" theme):

Social login widget bricks.png

Or if you use the "icons" theme:

Social login widget icons.png

Callback Implementation

This step is used to integrate social login with the user management system already in place on the website. We have APIs that allow this integration in a very simple way. The basic idea is to associate the user's "id" on social login and the user's "id" on your website. Two things can happen:

1. On the callback, the user's "id" is not related with any website user: in this case, a new user should be created (on the website) and associated with the social login user. If a user already exists (say, if the user created a traditional account), the user's account should be associated with the social login account.

2. On the callback, the user's "id" is already associated with a website user: in this case, the user should be logged in.

To get the user's "id" from Social Login, follow the steps explained on the "Call the API" screen:

Social login call api.png

Step 1: Extract the "token" parameter from POST data

We send via POST a parameter called "token" that identifies the user that just registered / logged in on the Social Login used on your website. Use this token to call the API and get the user's authentication information.

Step 2: Call our API to get the user's authentication information

Use the token you just got and your API secret to call the login/info API. You'll get back a JSON data structure with basic information about the user and the authentication method used by him/her.

URL to call:

  GET https://api.socialidnow.com/v1/marketing/login/info?api_secret=<secret>&token=<token>

Parameters:

  • api_secret: the "secret" you can get on the "Call the API" screen
  • token: the token returned on step 1

Step 3: Extract the user's "id" from the login/info response

When you call the login/info API you'll get a response like this:

Api login info.png

You can use the "id" field as a unique key to identify the user on your website. This is this user's "id" on Social Login.

Social Login user session

The login/info API returns another very important value: “connection_id”. We keep a session identification for every logged in user on Social Login to use in certain APIs and widgets (to make it easier to use these resources).

At the moment the user logs in on Social Login, we store a session cookie on his browser and track the "connection_id" so we can identify him automatically on certain widgets and APIs. Some RESTful APIs require the "connection_id" value, and so it is returned by the login/info API.

It's important to note that this "connection_id" value changes every time the user logs in, so it should only be used as a *session* identification method.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox