GooglePlus Authentication Provider Settings

If you use or want to use GooglePlus as your OAuth2 provider, you must understand some configuration details that will affect your application.

Google

Google changed their OAuth2 provider settings on 2014.9.1, and retired the old ones. If you use Google as your OAuth2 authentication provider, you should have changed your settings and scripts prior to this date.

Note: Google as an OAuth provider is no longer listed as a choice in the Business Manager Administration module.

To change your settings:

  1. In the Google console (https://console.developers.google.com/project), under APIs, make sure the Google+ API is enabled.
  2. Select Administration > Global Preferences > OAuth2 providers:
    1. Change the Scope field to email, profile.
    2. Change User Info URL field to https://www.googleapis.com/plus/v1/people/me.
  3. In the .ds script, parse the results.
  4. Change name accessors, as follows:

From:

profile.setFirstName(extProfile['given_name']);
profile.setLastName(extProfile['family_name']);
profile.setEmail(extProfile['email']);

To:

if (extProfile['name']) {
 profile.setFirstName(extProfile['name']['givenName']);
 profile.setLastName(extProfile['name']['familyName']);
 }
var emails : Array = extProfile['emails'];
if (emails && 0 < emails.length) {
 //first element of the array would be the account email according to Google:
 profile.setEmail(extProfile['emails'][0]['value']);
 }

GooglePlus

Instead of changing your Google OAuth provider settings as described previously, you should switch to the new GooglePlus OAuth2 provider that is automatically available in Salesforce B2C Commerce. However, if your customers have logged in using the Google provider, you must do some renaming to enable them to log in through GooglePlus.

The records in the database are keyed by provider id (Google or GooglePlus) and external id (whichever ID Google uses for a particular customer internally in their system). The external ID for a customer returned by Google is the same whether using the old or new provider.

After the change, you must ensure it's the same provider ID that was used when creating or logging in users through Google. One way to do this is to rename the legacy Google OAuth2 provider GoogleBAK, and then name the newly provisioned GooglePlus provider Google (or whatever name you're currently using in Business Manager for the current Google provider).

Related Links

Configuring OAuth Providers

https://developers.google.com/+/api/auth-migration#oauth2login

https://developers.google.com/accounts/docs/OAuth2

https://developers.google.com/oauthplayground/