question

doronhn avatar image
doronhn asked

is it possible to login a player by the Playfab unity SDK, and then "link" the account with google by JS sdk?

Hey,

is it possible to login a player by the Playfab unity SDK, and then "link" the account with google by JS sdk?

If so, how do i get the SessionTicket after i login?

why do i need this?

i am trying to set up google sign in into my WEBGL game, my sign in button is not at the start of the game, so the user already logged in.

https://docs.microsoft.com/en-us/gaming/playfab/features/authentication/platform-specific-authentication/google-html5

apissdks
10 |1200

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

doronhn avatar image
doronhn answered

Wow, that was hard. thanks for everyone for the help.
the answer is here - https://community.playfab.com/questions/39883/authentication-login-with-google-account-docs-and.html

turns out that the parameter "ServerAuthCode" is not correct, and need to be change to -"AccessToken".

so my request is -

PlayFabClientSDK.LinkGoogleAccount(
{
	ForceLink: true,
	AccessToken: accessToken
},onPlayFabResponse);
10 |1200

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

Seth Du avatar image
Seth Du answered

Yes, PlayFab is a service based on RESTful API, which is weakly correlated to the platform. Session ticket and entity token are contained in the callback result of login API. You may send through the session ticket/entity token to the JS script as the login identity.

In Unity, after the player is logged in successfully, you may also retrieve session ticket and entity token via PlayFabSettings.staticPlayer

For example:

PlayFabSettings.staticPlayer.ClientSessionTicket
6 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.

doronhn avatar image doronhn commented ·

Great! thanks!.

how do i add this "ClientSessionTicket" to the request header?

can you send me an exemple?

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

In JS SDK, you may set

PlayFab._internalSettings.sessionTicket = [your session ticket].

0 Likes 0 ·
doronhn avatar image doronhn commented ·

Great thanks,

doing that - got this error-

error: "InvalidAPIEndpoint" errorCode: 1131 errorMessage: "The URL for this request is not valid for this title. The correct API endpoint is https://XXX.playfabapi.com/" status: "BadRequest"

where do i set the endpoint?

thanks

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

I recommend you to read through the Quick Start for Javascript SDK on https://docs.microsoft.com/en-us/gaming/playfab/sdks/javascript/quickstart.

This error is usually caused by Title ID not set.

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

found it. thanks.

now i got this error -


this is the post URL:

https://1660.playfabapi.com/Client/LinkGoogleAccount?sdk=JavaScriptSDK-1.74.200914

{"code":400,"status":"BadRequest","error":"InvalidGoogleToken","errorCode":1026,"errorMessage":"Google API error code: invalid_grant details: Malformed auth code.","CallBackTimeMS":531,"Request":{"ForceLink":true,"ServerAuthCode":"ya29.a0AfH6SMBHj11VcWI8iSId5bhiI4Ezb2iX_R-aT9bGDFEaFzwSD5f4fY2W0sJiij8Z_0Js1y1owNy_s1WzNOOJIn5901y6BWEvece__lA0hPwKlYhf7lDmRGn-TBhPQYZxEZ3EQXBeswzvCPdNEyu6qQLPIZ5qBJuUz2E"}}

"errorCode":1026,"errorMessage":"Google API error code: invalid_grant details: Malformed auth code."

doing everything right...

0 Likes 0 ·
Show more comments
doronhn avatar image
doronhn answered

what do you mean by the way i request?

i am getting the AuthCode.

- i dont want to set android sign in.

- i want to set WEBGL sign in

where do i put this line? i cant find it anywhere

$client->setAccessType("offline");
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.