Case Custom Social Connection

Overview

This article will explain the steps needed to configure the custom social connection.

Applies To

  • Custom social connection

Solution

Follow the documentation to create a custom social connection

The general flow that is used in the custom social identity provider connection is the authorization code grant. It is described in the OAuth2 Authorization framework.  Additional documentation is available that provides the login process to these two endpoints. There can be minor variations between the destination IdP in parameters so it's best to review the source documentation on how best to configure this.

The Fetch User Profile default code does work for most providers but again there can be variations on this as each IdP has control over its own /userinfo endpoint. Generally the format is returned in JSON format and the provided template code can be used with none to very little change. Once again it's best to review documentation with the source IdP to determine the format and make changes from there.

Here is an example of the Fetch User Profile code (using Slack as the example): 
 

function(accessToken, ctx, cb) {
request.get(
    {
      url: 'https://slack.com/api/openid.connect.userInfo',
      headers: {
        'Authorization': 'Bearer ' + accessToken,
      }
    },
    (err, resp, body) => {
      if (err) {
        return cb(err);
      }
      if (resp.statusCode !== 200) {
        return cb(new Error(body));
      }
      let bodyParsed;
      try {
        bodyParsed = JSON.parse(body);
      } catch (jsonError) {
        return cb(new Error(body));
      }
      const profile = {
        user_id: bodyParsed["https://slack.com/user_id"],
        email: bodyParsed.email
      };
      cb(null, profile);
    }
  );
}

 

Recommended content

No recommended content found...