Socialid.login.startConnect

(Difference between revisions)
Jump to: navigation, search
(Redirect Connect Type)
(Parameters)
Line 48: Line 48:
 
| 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
 
|}
 
|}
  

Revision as of 20:03, 14 May 2018

Contents

Description

Starts the social connect process for the given provider to connect a new provider credential in the current login session. Can open a popup dialog or redirect to the provider, depending on the connectType.

This process allows to add credentials from different social networks to the same Social Login user. For example, a user can log in with its Facebook and add its Twitter credential, so the next time this user can choose to log in with its Facebook or Twitter account and be referenced as the same user by the website integrating with the Social Login platform.

Event Connect Type

When the connectType is set to "event", this API can trigger the following events:

The API works as follows:

In summary, it's important to handle these two events. In case of socialid.events.onLoginSuccess it's important to check the login token via server-side to certificate that the user logged in is the same associated to the current website session.

Redirect Connect Type

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

  • If there is a user already logged in the current session, the new credential is added to the user account and the user is redirected via HTTP POST to the redirect URI. The connection_id is passed along as the connection_id POST parameter.
  • If there is no user logged in the current session, an error is displayed to the user.

Usage

 socialid.login.startConnect(provider, options)

Parameters

provider required Determines which provider will be used in the connect process. Can be "facebook", "twitter", "linkedin" or "gplus".
options optional A Javascript object containing additional parameters.
redirectURI optional Overrides connectRedirectURI 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_connect" button:

 socialid.login.init(1, {connectType: "event"});
 facebook_button = document.getElementById("facebook_connect");
 facebook_button.onclick = function() {
   socialid.login.startConnect("facebook");
 };

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

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox