Socialid.login.init

(Difference between revisions)
Jump to: navigation, search
(Description)
Line 3: Line 3:
 
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.
 
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 an important option: the loginType. This option controls how the Social Login flow is executed in the browser. You can configure the loginType with one of these values:
+
This function takes two important options: '''loginType''' and '''redirectType'''. These options control how the Social Login 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]].
 
* 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]].
Line 9: Line 11:
 
* 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.
 
* 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.
  
The callback url used in the login types "callback" and "redirect" could be customized per request using the "redirectURI" option.
+
You can configure the '''redirectType''' 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.
 +
 
 +
The callback url used in the "callback" and "redirect" types can be customized per request using the "loginRedirectURI" and "connectRedirectURI" options. You can also use the "redirectURI" option to set both URIs to the same value.
  
 
== Usage ==
 
== Usage ==

Revision as of 15:20, 23 November 2017

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 two important options: loginType and redirectType. These options control how the Social Login 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 redirectType 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.

The callback url used in the "callback" and "redirect" types can be customized per request using the "loginRedirectURI" and "connectRedirectURI" 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".
redirectURI optional Define the callback url that must be called after the user logs in. Applied only to loginType "callback" or "redirect". If no redirectURI is defined, the default callback configured in the Social Login is used. 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"}

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"});

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", "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", 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