The SDK stores the auth token from the platform and uses it the next time it connects. This allows the device to remain logged in between application invocations. The authToken from the changes ever time the user connects, and the SDK manages this for you.
You can call the GameSparksApi.isAuthenticated() method to determine if the current player is authenticated or not
However, typing GameSparksApi.isAuthenticated() doesn't work. Its probably changed to something, please let me know.
I am trying to authenticate the player based on he name in a save file, to pull up his account details, rather than him having to click login every time.
but this doesnt help if the connection is lost when going through a tunnel, I'd have to check if authenticated, or connection has been dropped to the GS servers...
C
Charles Burt
said
over 8 years ago
Answer
found the answer:
if(GS.Authenticated)
print("authenticated");
C
Charles Burt
said
over 8 years ago
Would get good to know when player drops connection, so I can display a connection lost screen and hang the game
Customer Support
said
over 8 years ago
Charles, there is a Cloud Code event that is triggered when a Player is Disconnected but this is probably not much use to you in this case as you will have lost connectivity with the back end altogether. Is it an option for you to put some code into the Update () function on on of the main Unity objects?
if (!GS.Authenticated) {
// Do something in the game
}
M
Måns Ullerstam
said
about 8 years ago
I have a different problem, but it is related to isAuthenticated. If I call: GameSparksApi.isAuthenticated() in the start of the app life cycle, I always get false. So I can't keep the user logged in between app sessions. I have to start over every time.
My code does this:
- checks if isAuthenticated as soon as it starts
- if not (which is always the case), GameSparksApi.deviceAuthenticationRequest().send(); to create a user account no matter what
- then I ask them to login with Facebook, which is optional
- if they do, I successfully login again with Facebook, which should update the anonymous user created above
- If the first isAuthenticated request would be true, I would check if they have Facebook as well.
When I start the app again, I want the user to be automatically logged in all the way. However, when I start the app again, isAuthenticated is always false.
Do I need to to wait for "GS: Available" before I check isAuthenticated?
Thanks in advance!
D
David Reilly
said
over 6 years ago
Hey Måns, did you ever get a solution to your isAuthenticated issue? I am getting the same issue here.
Charles Burt
In the docs it says:
Authentication Caching
The SDK stores the auth token from the platform and uses it the next time it connects. This allows the device to remain logged in between application invocations. The authToken from the changes ever time the user connects, and the SDK manages this for you.
You can call the GameSparksApi.isAuthenticated() method to determine if the current player is authenticated or not
However, typing GameSparksApi.isAuthenticated() doesn't work. Its probably changed to something, please let me know.
I am trying to authenticate the player based on he name in a save file, to pull up his account details, rather than him having to click login every time.
found the answer:
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCharles Burt
I done this as a temporary workaround:
if player name already exists:
if(ES2.Exists("playerName") && authenticated == false)
{
AuthenticationResponse authResponse = new AuthenticationRequest ().SetUserName(playerName).SetPassword("password").Send();
if (authResponse.HasErrors) {
print("it didnt work");
} else {
print("it worked");
authenticated = true;
}
}
but this doesnt help if the connection is lost when going through a tunnel, I'd have to check if authenticated, or connection has been dropped to the GS servers...
Charles Burt
found the answer:
Charles Burt
Would get good to know when player drops connection, so I can display a connection lost screen and hang the game
Customer Support
Charles, there is a Cloud Code event that is triggered when a Player is Disconnected but this is probably not much use to you in this case as you will have lost connectivity with the back end altogether. Is it an option for you to put some code into the Update () function on on of the main Unity objects?
if (!GS.Authenticated) {
// Do something in the game
}
Måns Ullerstam
I have a different problem, but it is related to isAuthenticated. If I call: GameSparksApi.isAuthenticated() in the start of the app life cycle, I always get false. So I can't keep the user logged in between app sessions. I have to start over every time.
My code does this:
- checks if isAuthenticated as soon as it starts
- if not (which is always the case), GameSparksApi.deviceAuthenticationRequest().send(); to create a user account no matter what
- then I ask them to login with Facebook, which is optional
- if they do, I successfully login again with Facebook, which should update the anonymous user created above
- If the first isAuthenticated request would be true, I would check if they have Facebook as well.
When I start the app again, I want the user to be automatically logged in all the way. However, when I start the app again, isAuthenticated is always false.
Do I need to to wait for "GS: Available" before I check isAuthenticated?
Thanks in advance!
David Reilly
Hey Måns, did you ever get a solution to your isAuthenticated issue? I am getting the same issue here.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics