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.
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:
- 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 Login API
If you integrated Xsolla Login via API calls:
- When using the
Auth via social network call with a JWT standard, add thefields=email
parameter.
Example of the request:
- 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'
- When using the
Auth via social network call with an OAuth 2.0 protocol, add thescope=email
parameter.
Example of the request:
- 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?
Rate this page
Don’t want to answer
Thank you for your feedback!
Found a typo or other text error? Select the text and press Ctrl+Enter.