Should I call FacebookConnectRequest every time my game starts? Or only if the token is updated? Or not at all because it's handled on the GameSparks servers?
How does the expiry of the Facebook token get handled?
From the Facebook documentation:
"Native mobile apps using Facebook's SDKs will get long-lived access tokens, good for about 60 days. These tokens will be refreshed once per day when the person using your app makes a request to Facebook's servers. If no requests are made, the token will expire after about 60 days and the person will have to go through the login flow again to get a new token."
Does the token sent to the server on the initial FacebookConnectRequest get refreshed automatically? (perhaps to get an updated friends list once a day or something?
A Unity tutorial that contains optional Facebook login would be a great addition to the current documentation. I find it really hard to piece together what the correct and most efficient way is. It's all so opaque ;)
Best Answer
C
Customer Support
said
about 7 years ago
Hi Willem,
So if you have your state manager set up somewhat similar to below you would run this at the very beginning.
Once the game has been authorized by the user on Facebook, the token will be retrieved automatically when required. We are currently in the process of overhauling our documentation and tutorial sections of the website and will be covering these topics in much more depth, for now I hope this helps you.
Once the game has been authorized by the user on Facebook, the token will be retrieved automatically when required. We are currently in the process of overhauling our documentation and tutorial sections of the website and will be covering these topics in much more depth, for now I hope this helps you.
Thanks,
Liam
D
Domen Grabec
said
about 6 years ago
Hey Liam,
Could you please help with understanding the following. By the practices of Facebook's OAuth2 an access token received by a mobile device is only a short lived one. Facebook suggests that the backend server using an extension call prolongs the expiration of the short lived access token.
I also have a similar question as Willem. The tutorial makes it perfectly understandable how a short lived OAuth2 token is received and user is able to perform a Facebook & Gamesparks login. The questions that remain are:
- does Gamesparks automatically perform token extension call
- if yes Faceobook gives a new token to backend servers with longer expiration date
- how should a Facebook login be handled once the short lived token on clients side expires, and only the server has a valid long lived token?
Kind regards, Domen
1 person likes this
P
Peter Wiseman
said
about 5 years ago
I've been doing what's suggested .... log into Facebook each launch of the App and then call FacebookConnectRequest() with the token that FB supplies, but whenever I call FB.LogInWithReadPermissions(Permissions,FacebookAuthCallback); then Facebook always pops up an annoying screen saying "Confirm Login" .... "You previously logged in to ..... with Facebook. Would you like to continue". Is this normal or do I need to set something up in my Facebook App page to allow a silent login once a player has approved the Facebook permissions (which are only "public_proflle" and "user_friends") ? I'm using Unity 5.6.4f1 and Facebook for Unity SDK 7.10.0 and this is happening on both my iOS and Android devices.
M
Matt Timmermans
said
about 5 years ago
Hey Peter I'm new to gamesparks and I'm also using FB, iOS and Android, I would love to see your login/authentication code if possible, want to make sure I'm doing things right :S thanks
C
Christian Southgate
said
about 5 years ago
I have the exact same problem as Peter Wiseman, and the fix was to include the "client token" in the Facebook settings in Unity. You also need to enable "Native or desktop app" and "Is App Secret embedded in the client" in the advanced settings in the Facebook developer's site for your app. The client token is available on that same page.
I hope this helps someone :)
C
Christian Southgate
said
about 5 years ago
Update - this works great on Android, but on iOS the game was still bringing up the Facebook connect screen every time. This was because we were calling FB.LogInWithReadPermissions() every launch of the game. You're only supposed to do this once EVER unless the user actually logs out of Facebook.
Willem Kokke
Should I call FacebookConnectRequest every time my game starts? Or only if the token is updated? Or not at all because it's handled on the GameSparks servers?
How does the expiry of the Facebook token get handled?
From the Facebook documentation:
"Native mobile apps using Facebook's SDKs will get long-lived access tokens, good for about 60 days. These tokens will be refreshed once per day when the person using your app makes a request to Facebook's servers. If no requests are made, the token will expire after about 60 days and the person will have to go through the login flow again to get a new token."
Does the token sent to the server on the initial FacebookConnectRequest get refreshed automatically? (perhaps to get an updated friends list once a day or something?
A Unity tutorial that contains optional Facebook login would be a great addition to the current documentation. I find it really hard to piece together what the correct and most efficient way is. It's all so opaque ;)
Hi Willem,
So if you have your state manager set up somewhat similar to below you would run this at the very beginning.
Then you would log into Facebook and assign a delegate to run when Facebook has logged in. In there you call the GS connection request.
Once the game has been authorized by the user on Facebook, the token will be retrieved automatically when required. We are currently in the process of overhauling our documentation and tutorial sections of the website and will be covering these topics in much more depth, for now I hope this helps you.
Thanks,
Liam
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Willem,
So if you have your state manager set up somewhat similar to below you would run this at the very beginning.
Then you would log into Facebook and assign a delegate to run when Facebook has logged in. In there you call the GS connection request.
Once the game has been authorized by the user on Facebook, the token will be retrieved automatically when required. We are currently in the process of overhauling our documentation and tutorial sections of the website and will be covering these topics in much more depth, for now I hope this helps you.
Thanks,
Liam
Domen Grabec
Hey Liam,
Could you please help with understanding the following. By the practices of Facebook's OAuth2 an access token received by a mobile device is only a short lived one. Facebook suggests that the backend server using an extension call prolongs the expiration of the short lived access token.
I also have a similar question as Willem. The tutorial makes it perfectly understandable how a short lived OAuth2 token is received and user is able to perform a Facebook & Gamesparks login. The questions that remain are:
- does Gamesparks automatically perform token extension call
- if yes Faceobook gives a new token to backend servers with longer expiration date
- how should a Facebook login be handled once the short lived token on clients side expires, and only the server has a valid long lived token?
Kind regards, Domen
1 person likes this
Peter Wiseman
I've been doing what's suggested .... log into Facebook each launch of the App and then call FacebookConnectRequest() with the token that FB supplies, but whenever I call FB.LogInWithReadPermissions(Permissions, FacebookAuthCallback); then Facebook always pops up an annoying screen saying "Confirm Login" .... "You previously logged in to ..... with Facebook. Would you like to continue". Is this normal or do I need to set something up in my Facebook App page to allow a silent login once a player has approved the Facebook permissions (which are only "public_proflle" and "user_friends") ? I'm using Unity 5.6.4f1 and Facebook for Unity SDK 7.10.0 and this is happening on both my iOS and Android devices.
Matt Timmermans
Hey Peter I'm new to gamesparks and I'm also using FB, iOS and Android, I would love to see your login/authentication code if possible, want to make sure I'm doing things right :S thanks
Christian Southgate
I have the exact same problem as Peter Wiseman, and the fix was to include the "client token" in the Facebook settings in Unity. You also need to enable "Native or desktop app" and "Is App Secret embedded in the client" in the advanced settings in the Facebook developer's site for your app. The client token is available on that same page.
I hope this helps someone :)
Christian Southgate
Update - this works great on Android, but on iOS the game was still bringing up the Facebook connect screen every time. This was because we were calling FB.LogInWithReadPermissions() every launch of the game. You're only supposed to do this once EVER unless the user actually logs out of Facebook.
1 person likes this
-
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