Sign In Register

How can we help you today?

Start a new topic
Answered

Gamesparks automatically sending an AuthenticatedConnectRequest for a previously logged in user

Hello,  I'm working on a Kongregate authentication flow using Unity's WebGL build with some javascript, but is probably a similar authentication flow for any 3rd party login.


Basically what happens is that the first user to login works fine. However, if I log out the user on Kongregate, and then log in as someone else there seems to an issue.


Basically I believe that Gamesparks for Unity does something sensible when the application first starts it automatically logs you in to the last known Gamesparks user using an AuthenticatedConnectRequest such as:

request send socket1: {"@class":".AuthenticatedConnectRequest","hmac":"gfoeyZyfXvRrJv+5FS7zulFChZT1Kymtcp+dPLpyB8U=","os":"WP8","platform":"WebGLPlayer","deviceId":"67a2600f-fdd9-4f2e-88d2-d32dedd691cf","authToken":"blahblahblah"}


This returns successfully, but actually there is a different Kongregate user logged in on that same browser/machine than Gamesparks had previously stored. Thus when I try to do a 

request send socket1: {"@class":".KongregateConnectRequest","userId":"31181916","gameAuthToken":"1117867ca8de896e3fcf3d789969792c1d670e1e8724535c0a01378acaa4296e","requestId":"636132582001800000_0"}


I get an error response saying:

GS: RECV:{"@class":".AuthenticationResponse","error":{"accessToken":"ACCOUNT_ALREADY_LINKED"},"newPlayer":false,"requestId":"636132582001800000_0"}


Is the correct thing to do in this case to call GS.Reset() or GS.Disconnect() on the client? Or is there a way to suppress that first AuthenticatedConnectRequest from being sent in the first place given that I know I'll be getting the credentials from the 3rd party login system (in this case Kongregate)?


THanks for any help.



Best Answer

Hi Curt,


I think you are correct in your assessment of what is happening - the platform attempts to link the current player's account with the Kongregate social account, but because that player is already linked to a different Kongregate account, it returns an error.

When you send a social authentication request, you can set the "switchIfPossible" field to true (since you are not currently specifying this field, it is defaulting to false).

This will allow the currently authenticated player to be "switched" to another player (as opposed to giving the error you currently see) which I believe should solve the problem you are experiencing.


Hope this helps,


Jonathan.


Answer

Hi Curt,


I think you are correct in your assessment of what is happening - the platform attempts to link the current player's account with the Kongregate social account, but because that player is already linked to a different Kongregate account, it returns an error.

When you send a social authentication request, you can set the "switchIfPossible" field to true (since you are not currently specifying this field, it is defaulting to false).

This will allow the currently authenticated player to be "switched" to another player (as opposed to giving the error you currently see) which I believe should solve the problem you are experiencing.


Hope this helps,


Jonathan.

Ah, this is definitely helpful. I should have taken a closer look at the other parameters.  I did have one more question about the doNotLinkToCurrentPlayer parameter.  If I'm setting switchIfPossible to true, shouldn't I also set the doNotLinkToCurrentPlayer also to true? Or should I only set that to true if I know that the player has logged out. As far as I can tell Kongregate does not tell me if the player has logged out, so I'd need to store the last logged in user's name locally to figure that out...


Thanks in any case for the help, I'll try both ways and see what happens.


best,

Curt

Login to post a comment