Collecting emails during social authentication

How It Works

Most social networks do not share their users’ email addresses. Xsolla Login allows you to collect them when users authenticate via social networks and use the collected data to:

  • Export users’ emails to your Mailchimp account and send newsletters.
  • Allow users to reset the password and re-authenticate via both social network accounts and the email/password pair.

Note: If you have integrated Xsolla Launcher, emails are collected automatically without any additional settings.

Who Can Use It

Partners who have already integrated Login and whose users authenticate via social networks.

How to Get It

Depending on the Login integration flow, there are two ways to enable collecting emails:

Collecting Emails via the Login Widget

For the Login widget 2.0, you can also request users’ email addresses after social authentication. To set up requesting the email addresses:

  1. Go to Publisher Account in your Login project > General settings > Authorization > OAuth 2.0 authentication section.
  2. Set the Always collect user’s email at registration toggle to On.

For the previous version of the widget:

  • When using API methods with a JWT standard, add the fields=email parameter to the initialization code:

Copy
Full screen
Small screen
<script type="text/javascript">
XL.init({
  projectId: '[Login ID]',
  callbackUrl: '[callbackUrl]',
  locale: 'en_US',
  fields: 'email'
});
</script>

  • When using API methods with an OAuth 2.0 protocol, add the scope=email parameter to the initialization code:

Copy
Full screen
Small screen
<script type="text/javascript">
XL.init({
  projectId: '[Login ID]',
  locale: 'en_US',
  clientId: [client_id],
  responseType: 'code',
  scope: 'email',
  state: [custom_state],
  redirectUri: [redirect_uri]
});

Collecting Emails via API methods

If you integrated Xsolla Login via API methods:

  • When using the Auth via Social Network method with a JWT standard, add the fields=email parameter.

Example of the request:

Copy
Full screen
Small screen
GET https://login.xsolla.com/api/social/{providerName}/login_redirect?projectId={projectId}&fields=email&login_url={login_url}

  • When using the Auth via Social Network method with an OAuth 2.0 protocol, add the scope=email parameter.

Example of the request:

Copy
Full screen
Small screen
GET https://login.xsolla.com/api/oauth2/social/{providerName}/login_redirect?scope=email&client_id={client_id}&redirect_uri={redirect_uri}&state={state}&response_type=code