Authentification

Follow the step-by-step tutorials below to get going with the basic SDK features.

Connexion utilisateur par nom d'utilisateur/adresse e-mail et mot de passe

This tutorial shows how to use SDK methods to implement:
  • user sign-up
  • resend request for a sign-up confirmation email
  • user login
  • user password reset
Code source
Voir le code source des exemples sur GitHub.

You can authenticate users with their username or email address. In the following examples we authenticate users with their username, whereas the email address is used to confirm sign-up and to reset the password.

Note
If you use the Login widget on your site (in a web store, for example), make sure that you implemented the same user authentication methods on your site and in your application. The widget uses the email address for authentication by default. To set up user login via username, contact your Account Manager.

The logics and interface in the examples are less complicated than they will be in your application. A possible authentication system implementation option is described in the demo project.

Implémenter l'inscription utilisateur

Créer un widget

  1. Go to Content Browser and create a UI directory. In the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following interface elements:
    • username field
    • user email address field
    • user password field
    • sign-up button

The following picture shows an example of the page structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. Implement widget display when the level is started. To do this, add nodes as shown below. In the CreateWidget node, specify the created widget.

Ajouter la gestion des événements

  1. In the Hierarchy panel, select a sign-up button.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Link a RegisterUser method call on the XsollaLoginSubsystem object to the OnClicked node and add passing of data entered by users.
  3. Add callback functions:
    • OnRegistered — called if sign-up is successful
    • OnError — called if an error occurs
Note
In the example of event handling, callback functions use the PrintString class. A code and error description are passed in Code and Description parameters. You can add other actions. For example, open a confirmation email resend page after successful sign-up or a login page.
  1. To start widget debugging, start a level.

Example of event handling implementation:

Configurer un e-mail de confirmation d'inscription

After successful sign-up, a user receives a sign-up confirmation email to a specified address. You can customize emails sent to users in Publisher Account.

If you are developing an Android application, set up deep links to return a user to an application after they confirm sign-up.

Implémenter la demande utilisateur de renvoi d'e-mail de confirmation d'inscription

Créer un widget

  1. Go to Content Browser and open a UI directory. In the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following interface elements:
    • username/email field
    • resend email button

The following picture shows an example of the page structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. In the CreateWidget node, specify the created widget.

Ajouter la gestion des événements

  1. In the Hierarchy panel, select a resend email button.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Link a ResendAccountConfirmationEmail method call on the XsollaLoginSubsystem object to the OnClicked node and add passing of data entered by users.
  3. Add the OnEmailResent and OnError callback functions.
  4. To start widget debugging, start a level.

If the request is successful, the user receives a sign-up confirmation email to the email address specified during sign-up.

Example of event handling implementation:

Implémenter la connexion utilisateur

Créer un widget

  1. Go to Content Browser and open a UI directory. In the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following interface elements:
    • username field
    • password field
    • remember me checkbox
    • login button

The following picture shows an example of the page structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. In the CreateWidget node, specify the created widget.

Ajouter la gestion des événements

  1. In the Hierarchy panel, select a login button.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Link an AuthenticateUser method call on the XsollaLoginSubsystem object to the OnClicked node and add passing of data entered by users.
  3. Add the OnAuthenticated and OnError callback functions.
Note
After successful user login, the authorization token is passed in the LoginData parameter. The authorization token is used in requests to Xsolla servers.
  1. To start widget debugging, start a level.

Example of event handling implementation:

Implémenter la réinitialisation du mot de passe utilisateur

Créer un widget

  1. Go to Content Browser and open a UI directory. In the contextual menu, go to User Interface > Widget Blueprint.
  2. In the widget blueprint, add the following interface elements:
    • username/user email address field
    • password reset button

The following picture shows an example of the page structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. In the CreateWidget node, specify the created widget.

Ajouter la gestion des événements

  1. In the Hierarchy panel, select a password reset button.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Link a ResetUserPassword method call on the XsollaLoginSubsystem object to the OnClicked node and add passing of data entered by users.
  3. Add the OnEmailSent and OnError callback functions.
  4. To start widget debugging, start a level.

Example of event handling implementation:

After successful password reset request, the user receives an email with a password reset link. In Publisher Account > your Login project > General settings > URL > Callback URL, you can configure a URL address or a path a user is redirected to after successful authentication, email confirmation, or password reset.

Cet article vous a été utile ?
Merci !
Que pouvons-nous améliorer ? Message
Nous sommes désolés de l'apprendre
Dites-nous pourquoi vous n'avez pas trouvé cet article utile. Message
Merci pour votre commentaire !
Nous examinerons votre message et l'utiliserons pour améliorer votre expérience.
Masquer

Connexion via les réseaux sociaux

This guide shows how you can use SDK methods to implement user sign-up and login via their social network account.

Unlike for user authentication via username/user email address and password, you don’t have to implement separate logics for user sign-up. If the user’s first login is via a social network, a new account is created automatically.

If you have implemented social login in your application as an alternative authentication method, the social network account automatically links to an existing user account if the following conditions are met:

  • A user who signed up with username/email address and password logged into your application via a social network account.
  • A social network returns an email address.
  • User email address in a social network is the same as the email address used for sign-up in your application.
Code source
Voir le code source des exemples sur GitHub.
Note
You can implement manual linking of a social network account. Add the page to your application where users can link a social network account to their account. In the page controller, use the LinkSocialNetworkToUserAccount SDK method.

The examples show how to set up user login via a Twitter account. You can set up all social networks in the same way.

The logics and interface in the examples are less complicated than they will be in your application. A possible authentication system implementation option is described in the demo project.

Créer un widget

  1. Go to Content Browser and create a UI directory.
  2. In the contextual menu, go to User Interface > Widget Blueprint.
  3. In the widget blueprint, add the social login button.

The following picture shows an example of the page structure.

  1. Open a level blueprint:
    1. Choose a level in Content Browser.
    2. In the main menu, go to Blueprints > Open Level Blueprint.
  2. Implement widget display when the level is started. To do this, add nodes as shown below. In the CreateWidget node, specify the created widget.

Ajouter la gestion des événements

  1. In the Hierarchy panel, select a login button.
  2. In the Details panel, click the + icon near the On Clicked event.
  1. Open a Graph view.
  2. Implement a login page opening in a built-in browser:
    1. Link a GetSocialAuthenticationUrl method call connected with the XsollaLoginSubsystem object to the OnClicked node and add passing of data entered by users. Pass the Twitter value to the ProviderName parameter.
    2. Add the callback functions:
      • OnUrlReceived — called if you successfully receive a page URL. Received URL is passed in the Url parameter.
      • OnError — called if an error occurs.
Note
In the example of event handling, the OnError function uses the PrintString class. A code and error description are passed in Code and Description parameters. You can add other actions.
  1. Implement user login:
    1. Call the LaunchSocialAuthentication SDK methods linked to the XsollaLoginSubsystem object.
    2. Pass a login page URL.
  1. To get a token, track a login page URL change after successful user login:
    1. Implement closing of a browser after successful login.
    2. Call the OnSocialAuthCompleted method and subscribe to a BrowserClosed event.
Note
Getting a token from a URL is made by a blueprint of a built-in browser. The authorization token is passed to a LoginData parameter. Use it in requests to Xsolla servers.

Example of event handling implementation:

Cet article vous a été utile ?
Merci !
Que pouvons-nous améliorer ? Message
Nous sommes désolés de l'apprendre
Dites-nous pourquoi vous n'avez pas trouvé cet article utile. Message
Merci pour votre commentaire !
Nous examinerons votre message et l'utiliserons pour améliorer votre expérience.
Masquer
Cet article vous a été utile ?
Merci !
Que pouvons-nous améliorer ? Message
Nous sommes désolés de l'apprendre
Dites-nous pourquoi vous n'avez pas trouvé cet article utile. Message
Merci pour votre commentaire !
Nous examinerons votre message et l'utiliserons pour améliorer votre expérience.
Évaluer cette page
Évaluer cette page
Que pouvons-nous améliorer ?

Préfère ne pas répondre

Merci pour votre commentaire !
Dernière mise à jour: 10 Octobre 2023

Faute de frappe ou autre erreur dans le texte ? Sélectionnez le texte concerné et appuyez sur Ctrl+Entée.

Signaler un problème
Nous améliorons continuellement notre contenu grâce à vos commentaires.
Indiquez votre adresse e-mail pour un suivi
Merci pour votre commentaire !