question

Paulo avatar image
Paulo asked

Is there a way to log in with a Session Ticket and PlayFab ID?

Hi,

I'm launching my game through a launcher which logs the player in by using a LoginWithEmailAddress request. The game then receives from the launcher a PlayFabID and Session Ticket.

My question is, how to log in in PlayFab on game with the PlayFabID and Session Ticket received?

I'm using Unity SDK.

PS: I made a CloudScript that runs AuthenticateSessionTicket and it does return the user data with the session ticket I'm receiving from launcher. But to call this CloudScript the game needs to be already logged in, so to test I had to silently log in with a 'random' Custom ID first. But I think this custom ID login and session ticket received doesn't get connected whatsoever.

10 |1200

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

1 Answer

·
Seth Du avatar image
Seth Du answered

Short answer is that PlayFab doesn’t support login with PlayFab ID because it is not secure and PlayFab ID was designed to be able to be exposed to other players. Meanwhile, Session Ticket is the token that a player will be received after the successfully login, there is no need to authenticate it again on server side.

If you are using Unity SDK, I don’t think it necessary to call AuthenticateSessionTicket. You may notice that there will be a GameObject named PlayFabHttp in DontDestoryOnLoad when you have logged in at the launcher scene, which contains the session tickets and other things that PlayFab client API requires. After you have opened another Scene, you may directly call client APIs without login because normally, when this time, the session ticket should be valid. The player may only need to login again when the error reports that the session ticket is invalid.

Besides, AuthenticateSessionTicket can check if the ticket is valid, but normally, we use this API to retrieve player’s information via the session ticket, like last login time, title player entity key and so on.

2 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.

Paulo avatar image Paulo commented ·

Hi SethDu, when I mentioned launcher, I meant an outside software that launched the game, not a launcher scene. So this Launcher logs in on PlayFab and pass the login's PlayFabID and SessionTicket to the game via Command Line arguments. But then I'm not sure how to set the SessionTicket on PlayFab's Unity SDK or use it somehow to have the game auto log in. Does it have a way?

Thank you

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Paulo commented ·

Yes. You can set the authentication result via:

PlayFabSettings.staticPlayer.ClientSessionTicket = "";
PlayFabSettings.staticPlayer.PlayFabId = "";
PlayFabSettings.staticPlayer.EntityId = "";
PlayFabSettings.staticPlayer.EntityToken = "";
PlayFabSettings.staticPlayer.EntityType = "";

In addition, if you want to manage multiple players in the same client, you can define authentication context and add context in the API request.

PlayFabAuthenticationInstanceAPI context = new PlayFabAuthenticationInstanceAPI();
context.ClientSessionTicket = "";
context.PlayFabId = "";
PlayFabClientAPI.GetLeaderboard(
    new GetLeaderboardRequest {
        AuthenticationContext = context,
        ...
    },
    result=> { },
    error=>{ });

0 Likes 0 ·

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.