I can't find any code examples or methods in the SDK for logging the client out of GameSparks. How do I log the user out? (Unity SDK)
Best Answer
R
Rich Joslin
said
about 7 years ago
I managed to find some example code with GS.Reset() being used for logging out in the Unity client. Tested it and it works well. If I'm logged in with FB, then I need to also call FB.Logout at the same time.
If you need to disconnect from the client you can use GS.Disconnect() from cloud-code you can use Spark.getPlayer().disconnect(true);
R
Rich Joslin
said
about 7 years ago
Answer
I managed to find some example code with GS.Reset() being used for logging out in the Unity client. Tested it and it works well. If I'm logged in with FB, then I need to also call FB.Logout at the same time.
N
Nikita Novokreshchenov
said
about 5 years ago
Hey Rich!
Could you please provide the code you're talking about? Failed to find it myself :(
F
François Dujardin
said
over 4 years ago
I'm having the same issue. It really is not clear to me how to force a logout. In fact, even when I stop unity and restart it, GS.Authenticated becomes TRUE quickly without me doing any kind of login.
I also see that GS.GSPlatform.UserId stays stuck to a given id even when I call GS.Disconnect, or GS.Reset, or when I log in with a different user. That's really odd. It feels like the Unity SDK is not supporting login with different users on the same machine.
Am I missing something ?
Does anyone have code to logout properly and prevent authentication to happen "by magic" ?
E
Erik Boyer
said
over 4 years ago
@ François
Did you confirm that you are not getting a new user auth after calling GS.Disconnect?
Our current login requires Authentication before entering the game. We change users without even calling disconnect because authenticating ends the previous credentials and returns account data from the new login. In other words, we get multiple players on one device without explicit log out and support multiple users on one device - one at a time.
On a local log out call, we put a login in front of the player, they can either login or register. There is not a way to proceed without either. This method does not support 'remember me' or autologin or sustained sessions etc.
If you are allowing the user in based on GS.Authenticate, you should make sure you are not accepting device auth - there is only one allowed per machine. You will want to make sure you are allowing access on login and password credentials, and that the pair return with no errors.
I believe there is sample codefor Unity. in a script called something like gs_RegisterPlayers.
USe `GameSparks.Api.Requests.RegistrationRequest`
or `GameSparks.Api.Requests.AuthenticationRequest`
Rich Joslin
I can't find any code examples or methods in the SDK for logging the client out of GameSparks. How do I log the user out? (Unity SDK)
I managed to find some example code with GS.Reset() being used for logging out in the Unity client. Tested it and it works well. If I'm logged in with FB, then I need to also call FB.Logout at the same time.
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
from cloud-code you can use Spark.getPlayer().disconnect(true);
Rich Joslin
I managed to find some example code with GS.Reset() being used for logging out in the Unity client. Tested it and it works well. If I'm logged in with FB, then I need to also call FB.Logout at the same time.
Nikita Novokreshchenov
Hey Rich!
Could you please provide the code you're talking about?
Failed to find it myself :(
François Dujardin
I'm having the same issue. It really is not clear to me how to force a logout. In fact, even when I stop unity and restart it, GS.Authenticated becomes TRUE quickly without me doing any kind of login.
I also see that GS.GSPlatform.UserId stays stuck to a given id even when I call GS.Disconnect, or GS.Reset, or when I log in with a different user. That's really odd. It feels like the Unity SDK is not supporting login with different users on the same machine.
Am I missing something ?
Does anyone have code to logout properly and prevent authentication to happen "by magic" ?
Erik Boyer
@ François
Did you confirm that you are not getting a new user auth after calling GS.Disconnect?
Our current login requires Authentication before entering the game. We change users without even calling disconnect because authenticating ends the previous credentials and returns account data from the new login. In other words, we get multiple players on one device without explicit log out and support multiple users on one device - one at a time.
On a local log out call, we put a login in front of the player, they can either login or register. There is not a way to proceed without either. This method does not support 'remember me' or autologin or sustained sessions etc.
If you are allowing the user in based on GS.Authenticate, you should make sure you are not accepting device auth - there is only one allowed per machine. You will want to make sure you are allowing access on login and password credentials, and that the pair return with no errors.
I believe there is sample code for Unity. in a script called something like gs_RegisterPlayers.
USe `GameSparks.Api.Requests.RegistrationRequest`
or `GameSparks.Api.Requests.AuthenticationRequest`
and not `DeviceAuthenticationRequest`
-
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