Xsolla::Auth::XsollaAuth
Public Functions
| Name | |
|---|---|
| static bool | IsUserAuthenticated
() Checks if the user is authenticated. Returns true if the token exists and the user is authenticated. |
| static void | Register
(string username, string password, string email, Action< LoginLink
> onSuccess, Action< Error
> onError, string redirectUri =null, string state =null, string locale =null, bool? acceptConsent =null, bool? promoEmailAgreement =null, List< string > fields =null) Creates a new user account in the application and sends a sign-up confirmation email to the specified email address. To complete registration, the user should follow the link from the email. To disable email confirmation, contact your Account Manager. |
| static void | SignIn
(string username, string password, Action onSuccess, Action< Error
> onError, string redirectUri =null) Authenticates the user by the username/email and password specified via the authentication interface. |
| static void | StartAuthByEmail
(string email, Action< OperationId
> onSuccess, Action< Error
> onError, string redirectUri =null, string state =null, string locale =null, bool? sendLink =null, string linkUrl =null) Starts user authentication and sends an email with a one-time code and a link to the specified email address (if login via magic link is configured for the Login project) |
| static void | CompleteAuthByEmail
(string email, string confirmationCode, string operationId, Action onSuccess, Action< Error
> onError) Completes authentication after the user enters a one-time code or follows a link received in an email. |
| static void | StartAuthByPhoneNumber
(string phoneNumber, Action< OperationId
> onSuccess, Action< Error
> onError, string redirectUri =null, string state =null, bool? sendLink =null, string linkUrl =null) Starts user authentication and sends an SMS with a one-time code and a link to the specified phone number (if login via magic link is configured for the Login project). |
| static void | CompleteAuthByPhoneNumber
(string phoneNumber, string confirmationCode, string operationId, Action onSuccess, Action< Error
> onError) Completes authentication after the user enters a one-time code or follows a link received by SMS. |
| static void | ResetPassword
(string email, Action onSuccess, Action< Error
> onError, string redirectUri =null, string locale =null) Resets the user’s current password and sends an email to change the password to the email address specified during sign-up. |
| static void | ResendConfirmationLink
(string username, Action onSuccess, Action< Error
> onError, string redirectUri =null, string state =null, string locale =null) Resends a sign-up confirmation email to the specified email address. To complete registration, the user must follow the link from the email. |
| static void | AuthWithSocialNetworkAccessToken
(string accessToken, string accessTokenSecret, string openId, string provider, Action onSuccess, Action< Error
> onError, string redirectUri =null, string state =null) Authenticates the user with the access token using social network credentials. |
| static bool | Deprecated. Use AuthBySavedToken instead. Authenticates the user by saved token. Returns true if the token is loaded successfully and the user is authenticated |
| static void | AuthBySavedToken
(Action onSuccess, Action< Error
> onError) Authenticates user with the saved token. |
| static void | AuthWithXsollaWidget
(Action onSuccess, Action< Error
> onError, Action onCancel, string locale =null, SdkType sdkType =SdkType.Login) Authenticates the user with Xsolla Login widget. For standalone builds, the widget opens in the built-in browser that is included with the SDK. |
| static void | AuthViaXsollaLauncher
(Action onSuccess, Action< Error
> onError) Authenticates the user via Xsolla Launcher |
| static void | Logout
(Action onSuccess, Action< Error
> onError, LogoutType logoutType =LogoutType.All) Logs the user out and deletes the user session according to the value of the sessions parameter (OAuth2.0 only). |
| static void | SignInConsoleAccount
(string userId, string platform, Action onSuccess, Action< Error
> onError) Authenticates users who play on consoles or other platforms where Xsolla Login isn’t used. Requires server-side implementation. |
| static void | AuthViaDeviceID
(Action onSuccess, Action< Error
> onError, DeviceInfo
deviceInfo =null, string redirectUri =null, string state =null) Authenticates the user via a particular device ID. |
| static void | SilentAuth
(string providerName, string appId, string sessionTicket, Action onSuccess, Action< Error
> onError, string redirectUri =null, string state =null, string code =null) Authenticates a user by exchanging the session ticket from Steam, Xbox, or Epic Games to the JWT. |
| static string | GetSocialNetworkAuthUrl
(SocialProvider
provider, string redirectUri =null, string state =null) Returns URL for authentication via the specified social network in a browser. |
| static void | GetLinksForSocialAuth
(Action< SocialNetworkLinks
> onSuccess, Action< Error
> onError, string locale =null) Returns list of links for social authentication enabled in Publisher Account (your Login project > Authentication > Social login section). The links are valid for 10 minutes. You can get the link by this call and add it to your button for authentication via the social network. |
| static void | RefreshToken
(Action onSuccess, Action< Error
> onError, string redirectUri =null) Refreshes the token in case it is expired. Works only when OAuth 2.0 is enabled. |
| static void | ExchangeCodeToToken
(string code, Action onSuccess, Action< Error
> onError, string redirectUri =null, SdkType sdkType =SdkType.Login) Exchanges the user authentication code to a valid JWT. |
| static void | GetUserInfo
(Action< UserInfo
> onSuccess, Action< Error
> onError) Returns user details. |
| static void | AuthViaSocialNetwork
(SocialProvider
provider, Action onSuccess, Action< Error
> onError, Action onCancel) Authenticates user via an account in the specified social networks. |
Public Functions Documentation
function IsUserAuthenticated
- C#
1static bool IsUserAuthenticated()
Checks if the user is authenticated. Returns true if the token exists and the user is authenticated.
function Register
- C#
1static void Register(
2 string username,
3 string password,
4 string email,
5 Action< LoginLink > onSuccess,
6 Action< Error > onError,
7 string redirectUri =null,
8 string state =null,
9 string locale =null,
10 bool? acceptConsent =null,
11 bool? promoEmailAgreement =null,
12 List< string > fields =null
13)
Creates a new user account in the application and sends a sign-up confirmation email to the specified email address. To complete registration, the user should follow the link from the email. To disable email confirmation, contact your Account Manager.
Parameters:
- username Username.
- password User password.
- email User email address.
- onSuccess Called after successful user registration. An account confirmation message will be sent to the specified email address if not disabled.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0. - locale Defines localization of the email the user receives.
The following languages are supported: Arabic (ar_AE), Bulgarian (bg_BG), Czech (cz_CZ), German (de_DE), Spanish (es_ES), French (fr_FR), Hebrew (he_IL), Italian (it_IT), Japanese (ja_JP), Korean (ko_KR), Polish (pl_PL), Portuguese (pt_BR), Romanian (ro_RO), Russian (ru_RU), Thai (th_TH), Turkish (tr_TR), Vietnamese (vi_VN), Chinese Simplified (zh_CN), Chinese Traditional (zh_TW), English (en_XX, default).
- acceptConsent Whether the user gave consent to processing of their personal data.
- promoEmailAgreement User consent to receive the newsletter.
- fields Parameters used for extended registration form. To use this feature, please contact your Account Manager.
See: SignIn , ResetPassword , ResendConfirmationLink
function SignIn
- C#
1static void SignIn(
2 string username,
3 string password,
4 Action onSuccess,
5 Action< Error > onError,
6 string redirectUri =null
7)
Authenticates the user by the username/email and password specified via the authentication interface.
Parameters:
- username Username or email address.
- password User password.
- onSuccess Called after successful user authentication.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
See: SignInConsoleAccount , Register , ResetPassword , ResendConfirmationLink
function StartAuthByEmail
- C#
1static void StartAuthByEmail(
2 string email,
3 Action< OperationId > onSuccess,
4 Action< Error > onError,
5 string redirectUri =null,
6 string state =null,
7 string locale =null,
8 bool? sendLink =null,
9 string linkUrl =null
10)
Starts user authentication and sends an email with a one-time code and a link to the specified email address (if login via magic link is configured for the Login project)
Parameters:
- email User email address.
- onSuccess Called after successful email authentication start.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0. - locale Defines localization of the email the user receives. The following languages are supported: Arabic (
ar_AE), Bulgarian (bg_BG), Czech (cz_CZ), German (de_DE), Spanish (es_ES), French (fr_FR), Hebrew (he_IL), Italian (it_IT), Japanese (ja_JP), Korean (ko_KR), Polish (pl_PL), Portuguese (pt_BR), Romanian (ro_RO), Russian (ru_RU), Thai (th_TH), Turkish (tr_TR), Vietnamese (vi_VN), Chinese Simplified (zh_CN), Chinese Traditional (zh_TW), English (en_XX, default). - sendLink Shows whether a link is sent with the confirmation code in the email or not.
- linkUrl URL to redirect the user to the status authentication page.
function CompleteAuthByEmail
- C#
1static void CompleteAuthByEmail(
2 string email,
3 string confirmationCode,
4 string operationId,
5 Action onSuccess,
6 Action< Error > onError
7)
Completes authentication after the user enters a one-time code or follows a link received in an email.
Parameters:
- email User email address.
- confirmationCode Confirmation code.
- operationId Identifier of the confirmation code.
- onSuccess Called after successful email authentication.
- onError Called after the request resulted with an error.
function StartAuthByPhoneNumber
- C#
1static void StartAuthByPhoneNumber(
2 string phoneNumber,
3 Action< OperationId > onSuccess,
4 Action< Error > onError,
5 string redirectUri =null,
6 string state =null,
7 bool? sendLink =null,
8 string linkUrl =null
9)
Starts user authentication and sends an SMS with a one-time code and a link to the specified phone number (if login via magic link is configured for the Login project).
Parameters:
- phoneNumber User phone number.
- onSuccess Called after successful phone number authentication start.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0. - sendLink Shows whether a link is sent with the confirmation code in the SMS or not.
- linkUrl URL to redirect the user to the status authentication page.
function CompleteAuthByPhoneNumber
- C#
1static void CompleteAuthByPhoneNumber(
2 string phoneNumber,
3 string confirmationCode,
4 string operationId,
5 Action onSuccess,
6 Action< Error > onError
7)
Completes authentication after the user enters a one-time code or follows a link received by SMS.
Parameters:
- phoneNumber User phone number.
- confirmationCode Confirmation code.
- operationId Identifier of the confirmation code.
- onSuccess Called after successful phone number authentication.
- onError Called after the request resulted with an error.
function ResetPassword
- C#
1static void ResetPassword(
2 string email,
3 Action onSuccess,
4 Action< Error > onError,
5 string redirectUri =null,
6 string locale =null
7)
Resets the user’s current password and sends an email to change the password to the email address specified during sign-up.
Parameters:
- email Email to send the password change verification message to.
- onSuccess Called after successful user password reset.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- locale Defines localization of the email the user receives. The following languages are supported: Arabic (
ar_AE), Bulgarian (bg_BG), Czech (cz_CZ), German (de_DE), Spanish (es_ES), French (fr_FR), Hebrew (he_IL), Italian (it_IT), Japanese (ja_JP), Korean (ko_KR), Polish (pl_PL), Portuguese (pt_BR), Romanian (ro_RO), Russian (ru_RU), Thai (th_TH), Turkish (tr_TR), Vietnamese (vi_VN), Chinese Simplified (zh_CN), Chinese Traditional (zh_TW), English (en_XX, default).
See: Register , SignIn , ResendConfirmationLink
function ResendConfirmationLink
- C#
1static void ResendConfirmationLink(
2 string username,
3 Action onSuccess,
4 Action< Error > onError,
5 string redirectUri =null,
6 string state =null,
7 string locale =null
8)
Resends a sign-up confirmation email to the specified email address. To complete registration, the user must follow the link from the email.
Parameters:
- username Username or user email address.
- onSuccess Called after successful sending of the request.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0. - locale Defines localization of the email user receives. The following languages are supported: Arabic (
ar_AE), Bulgarian (bg_BG), Czech (cz_CZ), German (de_DE), Spanish (es_ES), French (fr_FR), Hebrew (he_IL), Italian (it_IT), Japanese (ja_JP), Korean (ko_KR), Polish (pl_PL), Portuguese (pt_BR), Romanian (ro_RO), Russian (ru_RU), Thai (th_TH), Turkish (tr_TR), Vietnamese (vi_VN), Chinese Simplified (zh_CN), Chinese Traditional (zh_TW), English (en_XX, default).
See: Register , SignIn , ResetPassword
function AuthWithSocialNetworkAccessToken
- C#
1static void AuthWithSocialNetworkAccessToken(
2 string accessToken,
3 string accessTokenSecret,
4 string openId,
5 string provider,
6 Action onSuccess,
7 Action< Error > onError,
8 string redirectUri =null,
9 string state =null
10)
Authenticates the user with the access token using social network credentials.
Parameters:
- accessToken Access token received from a social network.
- accessTokenSecret Parameter
oauth_token_secretreceived from the authorization request. Required for Twitter only. - openId Parameter
openidreceived from the social network. Required for WeChat only. - provider Name of the social network connected to Login in Publisher Account. Can be
facebook,google,linkedin,twitter,discord,naver,baidu,wechat, orqq_mobile. - onSuccess Called after successful user authentication on the specified platform.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0.
function AuthViaSavedToken
- C#
1static bool AuthViaSavedToken()
Authenticates the user by saved token. Returns true if the token is loaded successfully and the user is authenticated
function AuthBySavedToken
- C#
1static void AuthBySavedToken(
2 Action onSuccess,
3 Action< Error > onError
4)
Authenticates user with the saved token.
Parameters:
- onSuccess Called after successful authentication.
- onError Called after the request resulted with an error.
function AuthWithXsollaWidget
- C#
1static void AuthWithXsollaWidget(
2 Action onSuccess,
3 Action< Error > onError,
4 Action onCancel,
5 string locale =null,
6 SdkType sdkType =SdkType.Login
7)
Authenticates the user with Xsolla Login widget. For standalone builds, the widget opens in the built-in browser that is included with the SDK.
Parameters:
- onSuccess Called after successful authentication.
- onError Called after the request resulted with an error.
- onCancel Called after browser closing by user.
- locale Login widget UI language. Supported languages: Arabic (ar_AE), Bulgarian (bg_BG), Czech (cz_CZ), Filipino (fil-PH), English (en_XX), German (de_DE), Spanish (es_ES), French (fr_FR), Hebrew (he_IL), Indonesian (id-ID), Italian (it_IT), Japanese (ja_JP), Khmer (km-KH), Korean (ko_KR), Lao language ( lo-LA), Myanmar (my-MM), Nepali (ne-NP), Polish (pl_PL), Portuguese (pt_BR), Romanian (ro_RO), Russian (ru_RU), Thai (th_TH), Turkish (tr_TR), Vietnamese (vi_VN), Chinese Simplified (zh_CN), Chinese Traditional (zh_TW).
- sdkType SDK type. Used for internal analytics.
function AuthViaXsollaLauncher
- C#
1static void AuthViaXsollaLauncher(
2 Action onSuccess,
3 Action< Error > onError
4)
Authenticates the user via Xsolla Launcher
Parameters:
- onSuccess Called after successful authentication.
- onError Called after the request resulted with an error.
function Logout
- C#
1static void Logout(
2 Action onSuccess,
3 Action< Error > onError,
4 LogoutType logoutType =LogoutType.All
5)
Logs the user out and deletes the user session according to the value of the sessions parameter (OAuth2.0 only).
Parameters:
- onSuccess Called after successful user logout.
- onError Called after the request resulted with an error.
- logoutType Shows how the user is logged out and how the user session is deleted. Can be
ssoorall(default). Leave empty to use the default value.
function SignInConsoleAccount
- C#
1static void SignInConsoleAccount(
2 string userId,
3 string platform,
4 Action onSuccess,
5 Action< Error > onError
6)
Authenticates users who play on consoles or other platforms where Xsolla Login isn’t used. Requires server-side implementation.
Parameters:
- userId Social platform (XBox, PS4, etc) user unique identifier.
- platform Platform name (XBox, PS4, etc).
- onSuccess Called after successful user authentication. Authentication data including the JWT will be received.
- onError Called after the request resulted with an error.
Integration flow on the server side:
- Generate server JWT
- Connect OAuth 2.0 server client. Follow the instructions to connect the client and copy the Client ID and Secret key.
- Implement method: Generate JWT
with
application/x-www-form-urlencodedpayload parameters:- client_id=YOUR_CLIENT_ID
- client_secret=YOUR_CLIENT_SECRET
- grant_type=client_credentials
- Implement auth method Auth by custom ID
with:
- Query parameters
?publisher_project_id=XsollaSettings.StoreProjectId - Headers
Content-Type: application/jsonandX-SERVER-AUTHORIZATION: YourGeneratedJwt - More information about authentication via custom ID .
- Query parameters
function AuthViaDeviceID
- C#
1static void AuthViaDeviceID(
2 Action onSuccess,
3 Action< Error > onError,
4 DeviceInfo deviceInfo =null,
5 string redirectUri =null,
6 string state =null
7)
Authenticates the user via a particular device ID.
Parameters:
- onSuccess Called after successful user authentication via the device ID.
- onError Called after the request resulted with an error.
- deviceInfo Information about the device that is used to identify the user. if not specified, the method defines this infotmation automatically.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0.
function SilentAuth
- C#
1static void SilentAuth(
2 string providerName,
3 string appId,
4 string sessionTicket,
5 Action onSuccess,
6 Action< Error > onError,
7 string redirectUri =null,
8 string state =null,
9 string code =null
10)
Authenticates a user by exchanging the session ticket from Steam, Xbox, or Epic Games to the JWT.
Parameters:
- providerName Platform on which the session ticket was obtained. Can be
steam,xbox, orepicgames. - appId Platform application identifier.
- sessionTicket Session ticket received from the platform.
- onSuccess Called after successful user authentication with a platform session ticket. Authentication data including a JWT will be received.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long. Will be
xsollatestby default. Used only for OAuth2.0 auth. - code Code received from the platform.
function GetSocialNetworkAuthUrl
- C#
1static string GetSocialNetworkAuthUrl(
2 SocialProvider provider,
3 string redirectUri =null,
4 string state =null
5)
Returns URL for authentication via the specified social network in a browser.
Parameters:
- provider Name of a social network. Provider must be connected to Login in Publisher Account. Can be
amazon,apple,baidu,battlenet,discord,facebook,github,google,kakao,linkedin,mailru,microsoft,msn,naver,ok,paypal,psn,qq,reddit,steam,twitch,twitter,vimeo,vk,wechat,weibo,yahoo,yandex,youtube, orxbox. - redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- state Value used for additional user verification on backend. Must be at least 8 symbols long.
xsollatestby default. Required for OAuth 2.0.
function GetLinksForSocialAuth
- C#
1static void GetLinksForSocialAuth(
2 Action< SocialNetworkLinks > onSuccess,
3 Action< Error > onError,
4 string locale =null
5)
Returns list of links for social authentication enabled in Publisher Account (your Login project > Authentication > Social login section). The links are valid for 10 minutes. You can get the link by this call and add it to your button for authentication via the social network.
Parameters:
onSuccess Called after list of links for social authentication was successfully received.
onError Called after the request resulted with an error.
locale Region in the
language code_country codeformat, where:language code— language code in the ISO 639-1 format;country code— country/region code in the ISO 3166-1 alpha-2 format.
The list of the links will be sorted from most to least used social networks, according to the variable value.
function RefreshToken
- C#
1static void RefreshToken(
2 Action onSuccess,
3 Action< Error > onError,
4 string redirectUri =null
5)
Refreshes the token in case it is expired. Works only when OAuth 2.0 is enabled.
Parameters:
- onSuccess Called after successful token refreshing. Refresh data including the JWT will be received.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
function ExchangeCodeToToken
- C#
1static void ExchangeCodeToToken(
2 string code,
3 Action onSuccess,
4 Action< Error > onError,
5 string redirectUri =null,
6 SdkType sdkType =SdkType.Login
7)
Exchanges the user authentication code to a valid JWT.
Parameters:
- code Access code received from several other OAuth 2.0 requests (example: code from social network authentication).
- onSuccess Called after the code was successfully exchanged. The token is saved by the SDK, so the callback receives no data.
- onError Called after the request resulted with an error.
- redirectUri URI to redirect the user to after account confirmation, successful authentication, two-factor authentication configuration, or password reset confirmation. Must be identical to the OAuth 2.0 redirect URIs specified in Publisher Account. Required if there are several URIs.
- sdkType SDK type. Used for internal analytics.
function GetUserInfo
- C#
1static void GetUserInfo(
2 Action< UserInfo > onSuccess,
3 Action< Error > onError
4)
Returns user details.
Parameters:
- onSuccess Called after successful user details were successfully received.
- onError Called after the request resulted with an error.
function AuthViaSocialNetwork
- C#
1static void AuthViaSocialNetwork(
2 SocialProvider provider,
3 Action onSuccess,
4 Action< Error > onError,
5 Action onCancel
6)
Authenticates user via an account in the specified social networks.
Parameters:
- provider Name of a social network. Provider must be connected to Login in Publisher Account. Can be
amazon,apple,baidu,battlenet,discord,facebook,github,google,kakao,linkedin,mailru,microsoft,msn,naver,ok,paypal,psn,qq,reddit,steam,twitch,twitter,vimeo,vk,wechat,weibo,yahoo,yandex,youtube, orxbox. - onSuccess Called after successful user authentication.
- onError Called after the request resulted with an error.
- onCancel Called in case user closed browser.
Found a typo or other text error? Select the text and press Ctrl+Enter.