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:
- Go to Publisher Account in your Login project > General settings > Authorization > OAuth 2.0 authentication section.
- 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:
- html
<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:
- html
<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 API calls
If you integrated Xsolla Login via API calls:
- When using the
Auth via social network call with a JWT standard, add the fields=email parameter.
Example of the request:
- http
GET /api/social/{providerName}/login_redirect?projectId={projectId}&fields=email&login_url={login_url} HTTP/1.1
Host: login.xsolla.com
- When using the
Auth via social network call with an OAuth 2.0 protocol, add the scope=email parameter.
Example of the request:
- http
GET /api/oauth2/social/{providerName}/login_redirect?scope=email&client_id={client_id}&redirect_uri={redirect_uri}&state={state}&response_type=code HTTP/1.1
Host: login.xsolla.com
Was this article helpful?
Thank you for your feedback!
We'll review your message and use it to help us improve your experience.