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 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 calls 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_PROJECT_ID',
  callbackUrl: 'CALLBACK_URL',
  locale: 'en_US',
  fields: 'email'
});
</script>

  • When using API calls 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_PROJECT_ID',
  locale: 'en_US',
  clientId: 'CLIENT_ID',
  responseType: 'code',
  scope: 'email',
  state: 'CUSTOM_STATE',
  redirectUri: 'REDIRECT_URI'
});
</script>

Collecting emails via Login API

If you integrated Xsolla Login via API calls:

Example of the request:

Copy
Full screen
Small screen
http
  • http
  • curl
GET https://login.xsolla.com/api/social/{providerName}/login_redirect?projectId={projectId}&fields=email&login_url={login_url} HTTP/1.1
curl --request GET \
  --url 'https://login.xsolla.com/api/social/providerName/login_redirect?projectId=projectId&fields=email&login_url=login_url'

Example of the request:

Copy
Full screen
Small screen
http
  • http
  • curl
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 HTTP/1.1
curl --request GET \
  --url 'https://login.xsolla.com/api/oauth2/social/provider_name/login_redirect?scope=email&client_id=client_id&redirect_uri=redirect_uri&state=state&response_type=code'

Was this article helpful?
Thank you!
Is there anything we can improve? Message
We’re sorry to hear that
Please explain why this article wasn’t helpful to you. Message
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.
Rate this page
Rate this page
Is there anything we can improve?

Don’t want to answer

Thank you for your feedback!
Last updated: April 12, 2021

Found a typo or other text error? Select the text and press Ctrl+Enter.

Report a problem
We always review our content. Your feedback helps us improve it.
Provide an email so we can follow up
Thank you for your feedback!