question

daniel-bonifacio avatar image
daniel-bonifacio asked

About login to playfab using xsolla launcher

Hello, I'm starting to develop games and I really liked playfab.


I recently discovered the Xsolla, which despite being a monetization platform, I 
have been using it because of the great launcher it has.

I'm having a hard time logging my game on playfab through the xsolla launcher.

What I've done so far:
- I set up playfab on xsolla.
- Launcher is already using playfab information for login.
- I can get the JWT that the launcher creates and open the information inside
Unity.

My problem is that I don't know how to use the information in this jwt token to
log into playfab.

I saw in another topic in this forum an explanation of what to do, but I can't understand which code to use. From the token I get the information:

external_account_id
session_ticket
sub

I already appreciate the help
Daniel
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

daniel-bonifacio avatar image daniel-bonifacio commented ·

Sorry about the "code" format.

0 Likes 0 ·
Seth Du avatar image
Seth Du answered

Session ticket will be used as the identity of PlayFab Client API. I am not sure which PlayFab SDK you have implemented, basically you will only need to pass through the session ticket to the authentication context, which is defined in the SDK, so that player will be able to call client API.

The documentation provided by Xsolla is quite straight forward, external_account_id will be PlayFabID and session_ticket is the same as the one in PlayFab. If you are not familiar with those terminologies, you may start learning PlayFab API use from https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/ and it is also recommended to use POSTMAN to know how PlayFab API works. Please refer to: https://docs.microsoft.com/en-us/gaming/playfab/sdks/postman/

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

daniel-bonifacio avatar image daniel-bonifacio commented ·

Thank you very much! I will try.

0 Likes 0 ·
daniel-bonifacio avatar image daniel-bonifacio daniel-bonifacio commented ·

I studied the documentation you indicated and did the following in my PlayFabAuth.cs:

- I decoded the token generated by the Xsolla launcher, resulting in:

external_account_id = PLAYER PLAYFAB ID (TESTED IN POSTMAN)
session_ticket = PLAYER SESSION TICKET (TESTED IN POSTMAN)
0 Likes 0 ·
daniel-bonifacio avatar image daniel-bonifacio daniel-bonifacio commented ·

- So I wrote the code below to login, based on some examples on this forum:

PlayFabSettings.staticPlayer.ClientSessionTicket = "SESSION TOKEN";

PlayFabAuthenticationContext context = new PlayFabAuthenticationContext();
PlayFabClientAPI.LoginWithPlayFab(
  new LoginWithPlayFabRequest
  {   
  AuthenticationContext = context,
  },
  result => {
  //If the account is found
  message.text = "Bem vindo " + userlogin.text + ", Conecting...";
  IsAuthenticated = true;
  userName = userlogin.text.ToString();
  Debug.Log("Você está logado.");
  SceneManager.LoadScene(firstScene);
  }, error => {
  //If the account is not found
  message.text = "Fail to login [" + error.ErrorMessage + "]";
  IsAuthenticated = false;
  Debug.Log(error.ErrorMessage);
  }, null);
0 Likes 0 ·
Seth Du avatar image Seth Du ♦ daniel-bonifacio commented ·

With the session ticket, it is unnecessary to call LoginWithPlayFab anymore. The aim of calling login API is to retrieve a session ticket. Xsolla seems to have backend communication with PlayFab, which already has returned a session ticket. After you set up staticPlayer.ClientSessionTicket, you may try to call a client API directly, for example, getLeaderboard.

In addition, the PlayFabAuthenticationContext you have defined is empty, you may pass through session ticket to "context" so that you can use it in the request of client API (apart from login related API). Meanwhile, PlayFabSettings.staticPlayer.ClientSessionTicket is a global variable, you may either use PlayFabAuthenticationContext or set up global variable.

0 Likes 0 ·
daniel-bonifacio avatar image daniel-bonifacio daniel-bonifacio commented ·

When I run the game through the launcher I get the following error:

Invalid input parameters
UnityEngine.Debug:Log(Object)
PlayFabAuth:<LoginToken>b__14_1(PlayFabError) (at Assets/Resources/Scripts/PlayFabAuth.cs:116)
PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer) (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:260)
PlayFab.Internal.<Post>d__12:MoveNext() (at Assets/PlayFabSDK/Shared/Internal/PlayFabHttp/PlayFabUnityHttp.cs:190)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

What am I doing wrong? What is missing?

Thank you!

0 Likes 0 ·
daniel-bonifacio avatar image
daniel-bonifacio answered

Thank you very much! I will try.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.