Socialid.login.init

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Parameters)
(Parameters)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
== Description ==
 
== Description ==
  
Inicializa a API para ser usada por uma aplicação do social login. É obrigatório chamar esta função antes de usar qualquer recurso da API do Social Login.
+
Initializes the API to be used by a Social Login application. It's required to call this function to unlock the other Social Login APIs.
 +
 
 +
This function takes some important options: '''loginType''', '''connectType''' and '''sessionType'''. These options control how the flow is executed in the browser.
 +
 
 +
You can configure the '''loginType''' with one of the following values:
 +
 
 +
* event: the Social Login is performed in a popup and all the steps generate Javascript events. The browser is not redirect to any location, you should handle the login success through [[socialid.events.onLoginSuccess]].
 +
* callback: the Social Login is performed in a popup and at the end of the process the web page is redirected to the callback url configured in the Social Login dashboard. Intermediate login events are generated.
 +
* redirect: the Social Login is performed via redirects in the following order: website > socialid > social network > socialid > website callback. Popup is not used in this case. This option is useful for places where the browser is limited and cannot use popups.
 +
 
 +
You can configure the '''connectType''' with one of the following values:
 +
 
 +
* event: the Social Connect is performed in a popup and all the steps generate Javascript events. The browser is not redirect to any location, you should handle the connect success through [[socialid.events.onConnectSuccess]].
 +
* redirect: the Social Connect is performed via redirects in the following order: website > socialid > social network > socialid > website callback. Popup is not used in this case. This option is useful for places where the browser is limited and cannot use popups.
 +
 
 +
You can configure the '''sessionType''' with one of the following values:
 +
 
 +
* event: the Session creation is performed in a popup and all the steps generate Javascript events. The browser is not redirect to any location, you should handle the creation success through [[socialid.events.onSessionSuccess]].
 +
* callback: the Session creation is performed in a popup and at the end of the process the web page is redirected to the callback url configured in the Social Login dashboard. Intermediate session events are generated.
 +
* redirect: the Session creation is performed via redirects in the following order: website > socialid > website callback. Popup is not used in this case. This option is useful for places where the browser is limited and cannot use popups.
 +
 
 +
The callback url used in the "callback" and "redirect" types can be customized per request using the "loginRedirectURI", "connectRedirectURI" or "sessionRedirectURI" options. You can also use the "redirectURI" option to set both URIs to the same value.
  
 
== Usage ==
 
== Usage ==
Line 11: Line 32:
 
{|
 
{|
 
! align="left" width="200px" | appId
 
! align="left" width="200px" | appId
| width="200px" | obrigatório
+
| width="200px" | required
| o identificador numérico da aplicação do social login
+
| The identifier number of the Social Login application.
 
|+
 
|+
 
! align="left" width="200px" | options
 
! align="left" width="200px" | options
| width="200px" | opcional
+
| width="200px" | optional
| um objeto contendo parâmetros adicionais
+
| A Javascript object containing additional parameters.
 
|+
 
|+
 
! align="left" width="200px" style="padding-left: 20px" | loginType
 
! align="left" width="200px" style="padding-left: 20px" | loginType
| width="200px" | opcional
+
| width="200px" | optional
| Pode ser "callback" ou "event". Especifica se após um [[socialid.events.onLoginSuccess|onLoginSuccess]] a página será redirecionada automaticamente para o callback_url ("callback") ou se apenas o evento será gerado ("event"). Default: "event".
+
| Define how the Social Login will be performed in the browser (see the description above). Can be "callback", "event" or "redirect". Default: "event".
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | connectType
 +
| width="200px" | optional
 +
| Define how the Social Connect will be performed in the browser (see the description above). Can be "event" or "redirect". Default: "event".
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | sessionType
 +
| width="200px" | optional
 +
| Define how the User's Session creation will be performed in the browser (see the description above). Can be "callback", "event" or "redirect". Default: "event".
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | loginRedirectURI
 +
| width="200px" | optional
 +
| Define the callback url that must be called after the user logs in. Applied only to loginType "callback" or "redirect". If no loginRedirectURI is defined, the redirectURI parameter is used. If no redirectUR is defined, the default callback configured in the Social Login is used. The loginRedirectURI domain must be allowed in the Social Login domains whitelist.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | connectRedirectURI
 +
| width="200px" | optional
 +
| Define the callback url that must be called after the user connects. Applied only to connectType "redirect". If no connectRedirectURI is defined, the redirectURI parameter is used. If no redirectUR is defined, the default callback configured in the Social Login is used. The connectRedirectURI domain must be allowed in the Social Login domains whitelist.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | sessionRedirectURI
 +
| width="200px" | optional
 +
| Define the callback url that must be called after the user's session is created. Applied only to sessionType "redirect". If no sessionRedirectURI is defined, the redirectURI parameter is used. If no redirectUR is defined, the default callback configured in the Social Login is used. The sessionRedirectURI domain must be allowed in the Social Login domains whitelist.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | redirectURI
 +
| width="200px" | optional
 +
| Default callback url that must be called after the user logs in, connects or a session is created. The redirectURI domain must be allowed in the Social Login domains whitelist.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | scope
 +
| width="200px" | optional
 +
| Define custom scopes for OAuth2 providers when the user logs in. Must be an object mapped by provider name, containing the scopes in a comma separated format. Example: {"facebook": "email,user_likes"}
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | errorRedirect
 +
| width="200px" | optional
 +
| Whether to redirect the user to the callback url when an error occurs. Applied only to loginType/connectType/sessionType "redirect". Default: false
 
|}
 
|}
  
 
== Example ==
 
== Example ==
  
Inicializando a API do Social Login para user usado pela aplicação de id "1" e gerando eventos a serem tratados por Javascript ("event"), sem redirecionar automaticamente para o callback_url cadastrado na aplicação:
+
This example initializes the Social Login API to be used by the application with id "1" and defines the Social Login flow to generate Javascript events to handle the login responses, without redirects to the callback_url configured in the Social Login dashboard:
 +
 
 +
  socialid.login.init(1, {loginType: "event", connectType: "event"});
 +
 
 +
The following example initializes the Social Login API to be used by the application with id "567" and defines the Social Login flow to redirect to the "http://example.com/social_login" (the example.com domain must be white labeled) callback url after the user complete the social login:
 +
 
 +
  socialid.login.init(567, {loginType: "redirect", connectType: "redirect", "redirectURI": "http://example.com/social_login"});
 +
 
 +
The following example initializes the Social Login API to be used by the application with id "982" and defines a custom OAuth2 scope for the Facebook provider when the user logs in:
  
   socialid.login.init(1, {loginType: "event"});
+
   socialid.login.init(982, {loginType: "event", connectType: "event", scope: {facebook: "email,user_likes"}});
  
Teste os parâmetros 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 20:07, 12 July 2021

Contents

Description

Initializes the API to be used by a Social Login application. It's required to call this function to unlock the other Social Login APIs.

This function takes some important options: loginType, connectType and sessionType. These options control how the flow is executed in the browser.

You can configure the loginType with one of the following values:

  • event: the Social Login is performed in a popup and all the steps generate Javascript events. The browser is not redirect to any location, you should handle the login success through socialid.events.onLoginSuccess.
  • callback: the Social Login is performed in a popup and at the end of the process the web page is redirected to the callback url configured in the Social Login dashboard. Intermediate login events are generated.
  • redirect: the Social Login is performed via redirects in the following order: website > socialid > social network > socialid > website callback. Popup is not used in this case. This option is useful for places where the browser is limited and cannot use popups.

You can configure the connectType with one of the following values:

  • event: the Social Connect is performed in a popup and all the steps generate Javascript events. The browser is not redirect to any location, you should handle the connect success through socialid.events.onConnectSuccess.
  • redirect: the Social Connect is performed via redirects in the following order: website > socialid > social network > socialid > website callback. Popup is not used in this case. This option is useful for places where the browser is limited and cannot use popups.

You can configure the sessionType with one of the following values:

  • event: the Session creation is performed in a popup and all the steps generate Javascript events. The browser is not redirect to any location, you should handle the creation success through socialid.events.onSessionSuccess.
  • callback: the Session creation is performed in a popup and at the end of the process the web page is redirected to the callback url configured in the Social Login dashboard. Intermediate session events are generated.
  • redirect: the Session creation is performed via redirects in the following order: website > socialid > website callback. Popup is not used in this case. This option is useful for places where the browser is limited and cannot use popups.

The callback url used in the "callback" and "redirect" types can be customized per request using the "loginRedirectURI", "connectRedirectURI" or "sessionRedirectURI" options. You can also use the "redirectURI" option to set both URIs to the same value.

Usage

 socialid.login.init(appId, options)

Parameters

appId required The identifier number of the Social Login application.
options optional A Javascript object containing additional parameters.
loginType optional Define how the Social Login will be performed in the browser (see the description above). Can be "callback", "event" or "redirect". Default: "event".
connectType optional Define how the Social Connect will be performed in the browser (see the description above). Can be "event" or "redirect". Default: "event".
sessionType optional Define how the User's Session creation will be performed in the browser (see the description above). Can be "callback", "event" or "redirect". Default: "event".
loginRedirectURI optional Define the callback url that must be called after the user logs in. Applied only to loginType "callback" or "redirect". If no loginRedirectURI is defined, the redirectURI parameter is used. If no redirectUR is defined, the default callback configured in the Social Login is used. The loginRedirectURI domain must be allowed in the Social Login domains whitelist.
connectRedirectURI optional Define the callback url that must be called after the user connects. Applied only to connectType "redirect". If no connectRedirectURI is defined, the redirectURI parameter is used. If no redirectUR is defined, the default callback configured in the Social Login is used. The connectRedirectURI domain must be allowed in the Social Login domains whitelist.
sessionRedirectURI optional Define the callback url that must be called after the user's session is created. Applied only to sessionType "redirect". If no sessionRedirectURI is defined, the redirectURI parameter is used. If no redirectUR is defined, the default callback configured in the Social Login is used. The sessionRedirectURI domain must be allowed in the Social Login domains whitelist.
redirectURI optional Default callback url that must be called after the user logs in, connects or a session is created. The redirectURI domain must be allowed in the Social Login domains whitelist.
scope optional Define custom scopes for OAuth2 providers when the user logs in. Must be an object mapped by provider name, containing the scopes in a comma separated format. Example: {"facebook": "email,user_likes"}
errorRedirect optional Whether to redirect the user to the callback url when an error occurs. Applied only to loginType/connectType/sessionType "redirect". Default: false

Example

This example initializes the Social Login API to be used by the application with id "1" and defines the Social Login flow to generate Javascript events to handle the login responses, without redirects to the callback_url configured in the Social Login dashboard:

 socialid.login.init(1, {loginType: "event", connectType: "event"});

The following example initializes the Social Login API to be used by the application with id "567" and defines the Social Login flow to redirect to the "http://example.com/social_login" (the example.com domain must be white labeled) callback url after the user complete the social login:

 socialid.login.init(567, {loginType: "redirect", connectType: "redirect", "redirectURI": "http://example.com/social_login"});

The following example initializes the Social Login API to be used by the application with id "982" and defines a custom OAuth2 scope for the Facebook provider when the user logs in:

 socialid.login.init(982, {loginType: "event", connectType: "event", scope: {facebook: "email,user_likes"}});

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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox