I’m trying to do the following flow for authentication, can you please correct me where i’m going wrong.
(Note : im testing on editor only for now)
First time login to the app calls
AuthenticationService.Instance.SignInAnonymouslyAsync()
: So that player just gets into the game first, and then later decide if they want to continue with social login.
(because if a session token exists, the same method retrieves the sign in information, and if no session token exists it creates a new user anyways)
From a seperate access point, i’m providing access to do social login, via :
PlayerAccountService.Instance.StartSignInAsync()
Query 1 : is there an alternative to this in AuthenticationService?
Query 2 : whats the difference between , and which one to use when?
PlayerAccountService.Instance.SignedIn
and
AuthenticationService.Instance.SignedIn ?
Query 3 : the
AuthenticationService.Instance.PlayerInfo.Identities count is ZERO, is this expected behaviour?
since i used google account to login, i was expecting to see atleast google login to show up in this identities list, am i missing something?
Now after completing step 2, the user logs in fine, and when exited and logging back in works fine.
And this playerID is stored in player accounts and i can access it from dashboards.
But, when i start afresh by calling
AuthenticationService.Instance.SignOut(); and then,
and try to login, a new anonymous id is created on the first login (as expected)
BUT,
when, i do social login now, in the dashboard this new user is visible (the new user from the new anonymous sign in)
Shouldn’t i be getting the same playerID back from the social login which was originally linked?
Am i missing something here in the flow?
Any help here in clearing my understanding is highly appreciated.
Correct, try anonymous sign in first. You could also check if a session token exists before doing so.
I believe PlayerAccountService is an older API and replaced by AuthenticationService. The PlayerInfo is invalid until after you called GetPlayerInfoAsync which requires the player to be signed in.
Or both in one call: AuthenticationService.Instance.SignOut(true)
Did you call the corresponding LinkWith… method? There’s one for every social account, ie Apple, Steam, Facebook.
I hope I get this right … this is what the flow would look like:
anonymous sign-in
call AuthenticationService GetPlayerInfoAsync
EXIT conditions:
player is signed in AND
player has linked account according to playerinfo
call external ID provider login API to obtain the provider specific sign-in “auth token(s)” which go by various names depending on the provider: token, identity, ticket, nonce, userId, …
call AuthenticationService SignInWith(ExternalProvider) using above “auth token(s)”
call AuthenticationService GetPlayerInfoAsync
EXIT condition:
account is already linked according to playerinfo
call AuthenticationService LinkWith(TheProvider) to establish the link!
This is only a simplified version and does not cover re-linking to another ID provider, or linking to multiple, or unlinking. And they say “login is easy” …