Socialid.login.startLogin

From Social ID Developers
(Difference between revisions)
Jump to: navigation, search
(Parameters)
 
(6 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
Starts the social login process for the given provider. Can open a popup dialog or redirect to the provider, depending on the [[socialid.login.init|loginType]].
 
Starts the social login process for the given provider. Can open a popup dialog or redirect to the provider, depending on the [[socialid.login.init|loginType]].
 +
 +
==== Event Login Type ====
  
 
When the [[socialid.login.init|loginType]] is set to ''"event"'', this method can trigger the following events:
 
When the [[socialid.login.init|loginType]] is set to ''"event"'', this method can trigger the following events:
Line 8: Line 10:
 
* [[socialid.events.onLoginCancel]]
 
* [[socialid.events.onLoginCancel]]
 
* [[socialid.events.onLoginError]]
 
* [[socialid.events.onLoginError]]
 +
 +
==== Redirect Login Type ====
 +
 +
When the [[socialid.login.init|loginType]] is set to ''"redirect"'', the API works as follows:
 +
 +
* If no error occurs, the user is redirected via HTTP POST to the redirect URI after the login succeeds. The [[Social Login Tokens|login_token]] is passed along as the '''token''' POST parameter.
 +
 +
* In case of error, the [[socialid.login.init|errorRedirect]] flag controls the flow. If set to '''false''', an error message is displayed to the user. If set to '''true''', the user is redirected to the [[socialid.login.init|loginRedirectURI]] via HTTP GET with the following query parameters:
 +
 +
{|
 +
! align="left" width="200px" | error
 +
| An error code as defined in the [https://tools.ietf.org/html/rfc6749#section-4.2.2.1 OAuth2 specs]. Possible values are:
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | unauthorized_client
 +
| The client is not authorized.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | access_denied
 +
| The resource owner or authorization server denied the request.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | server_error
 +
| The authorization server encountered an unexpected condition that prevented it from fulfilling the request.
 +
|+
 +
! align="left" width="200px" | error_code
 +
| A custom error code with more details about the error. Possible values are:
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | unauthorized
 +
| It wasn't possible to get the access token for the user because the login code expired or the application credentials are invalid.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | blocked
 +
| This Account is not receiving new logins because it hit the maximum number of contacts for its plan.
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | user_inactive
 +
| The user is inactive. See: [[PUT login/users/:user_id/activate]]
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | internal_server_error
 +
| An unknown error occurred.
 +
|+
 +
! align="left" width="200px" | error_description
 +
| A user friendly message describing the error.
 +
|}
 +
 +
In case the connectionStorageType is set to '''cookie''', at the redirect URI, the received Connection ID parameter, must be saved into a cookie with the same name given at connectionStorageOptions.
 +
 +
In case the connectionStorageType is set to '''localStorage''', after the redirect URI, the received Connection ID parameter, must be saved as a local storage item with the same
 +
name given at connectionStorageOptions.
 +
 +
In case the connectionStorageType is set to '''sessionStorage''', after the redirect URI, the received Connection ID parameter, must be saved as a session storage item with the same name given at connectionStorageOptions.
 +
 +
==== Callback Login Type ====
 +
 +
When the [[socialid.login.init|loginType]] is set to ''"callback"'', the API opens a popup and behaves just like the ''"event"'' loginType until the end of the login process. All login events can also be generated. However, at the end of a successful login, the user is redirected to the redirect URI following the same flow described for the ''"redirect"'' loginType.
  
 
== Usage ==
 
== Usage ==
Line 18: Line 71:
 
! align="left" width="200px" | provider
 
! align="left" width="200px" | provider
 
| width="200px" | required
 
| width="200px" | required
| Determines which provider will be used in the login process. Can be "facebook", "twitter", "linkedin" or "gplus".  
+
| Determines which provider will be used in the login process. Can be "facebook", "twitter", "linkedin", "gplus", "instagram" or "apple".  
 
|+
 
|+
 
! align="left" width="200px" | options
 
! align="left" width="200px" | options
Line 31: Line 84:
 
| width="200px" | optional
 
| width="200px" | optional
 
| Overrides [[socialid.login.init|scope]] parameter
 
| Overrides [[socialid.login.init|scope]] parameter
 +
|+
 +
! align="left" width="200px" style="padding-left: 20px" | errorRedirect
 +
| width="200px" | optional
 +
| Overrides [[socialid.login.init|errorRedirect]] parameter
 
|}
 
|}
  

Latest revision as of 16:35, 30 December 2021

Contents

Description

Starts the social login process for the given provider. Can open a popup dialog or redirect to the provider, depending on the loginType.

Event Login Type

When the loginType is set to "event", this method can trigger the following events:

Redirect Login Type

When the loginType is set to "redirect", the API works as follows:

  • If no error occurs, the user is redirected via HTTP POST to the redirect URI after the login succeeds. The login_token is passed along as the token POST parameter.
  • In case of error, the errorRedirect flag controls the flow. If set to false, an error message is displayed to the user. If set to true, the user is redirected to the loginRedirectURI via HTTP GET with the following query parameters:
error An error code as defined in the OAuth2 specs. Possible values are:
unauthorized_client The client is not authorized.
access_denied The resource owner or authorization server denied the request.
server_error The authorization server encountered an unexpected condition that prevented it from fulfilling the request.
error_code A custom error code with more details about the error. Possible values are:
unauthorized It wasn't possible to get the access token for the user because the login code expired or the application credentials are invalid.
blocked This Account is not receiving new logins because it hit the maximum number of contacts for its plan.
user_inactive The user is inactive. See: PUT login/users/:user_id/activate
internal_server_error An unknown error occurred.
error_description A user friendly message describing the error.

In case the connectionStorageType is set to cookie, at the redirect URI, the received Connection ID parameter, must be saved into a cookie with the same name given at connectionStorageOptions.

In case the connectionStorageType is set to localStorage, after the redirect URI, the received Connection ID parameter, must be saved as a local storage item with the same name given at connectionStorageOptions.

In case the connectionStorageType is set to sessionStorage, after the redirect URI, the received Connection ID parameter, must be saved as a session storage item with the same name given at connectionStorageOptions.

Callback Login Type

When the loginType is set to "callback", the API opens a popup and behaves just like the "event" loginType until the end of the login process. All login events can also be generated. However, at the end of a successful login, the user is redirected to the redirect URI following the same flow described for the "redirect" loginType.

Usage

 socialid.login.startLogin(provider, options)

Parameters

provider required Determines which provider will be used in the login process. Can be "facebook", "twitter", "linkedin", "gplus", "instagram" or "apple".
options optional A Javascript object containing additional parameters.
redirectURI optional Overrides loginRedirectURI parameter
scope optional Overrides scope parameter
errorRedirect optional Overrides errorRedirect parameter

Example

It opens a popup starting the login dialog with Facebook when the user clicks on the "facebook_login" button:

 socialid.login.init(1, {loginType: "event"});
 facebook_button = document.getElementById("facebook_login");
 facebook_button.onclick = function() {
   socialid.login.startLogin("facebook");
 };

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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox