question

Talha avatar image
Talha asked

login workflow (confusion about facebook)

Background: creating unity 2d game.

Hi, So let me get this straight this is how it goes

user installs game-> opens game -> is logged in with mobiledeviceID, then we prompt them to link account with facebook. they link account with facbook.

device1 = logged in with facebook and deviceID.

now they pick up another phone. they open game-> we log them in with mobiledeviceID2, then prompt them to link with either an existing facebook account or create new facebook account.

they choose the existing option.

we then link both devices to the single facebook account. Is that alright?

now there are two phones with 1 player on it. how many entries will there be for that player in players Tab?

but what do we check first in our script? are we logging the player, every time they start the game, by the deviceID?

could you be so kind to write a basic algorithm for it? (just a logical approach, i have checked out almost all tutorials on it and am still stuck)

main confusion is how facebook login works?

like okay we have logged in but tokens are giving me a headache,what are they? where do we get them? (like in the function?) i dont understand why we need them, why they expire etc?

how to refresh them? how to get app permissions from facebook ?

i guess the main benefit of using facebook is just friends list (apart from that its basically useless right?)

unity3d
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Talha avatar image Talha commented ·

so i have been searching this whole time. General discussions and other resources. So far what i have grasped is that we need to call the loginwithfacebook function after a while because the access token expires after two hours or so. now what i've learned is that

we can link several device ids to same facebook account. we can use device id to retrieve the user data. but in order to use fbs features we need to give playfab the access token so that you can do your bit, we can do that by calling linkfacebookaccount function right?

how do we get the token? from void abc(facebookloginresult result)? then using result to get the access token?am i right?

does that mean user has to login everytime manually from his phone(by typing email and password) for us to get the token? how does that work?

if we are using a device that was already linked to a facebook account. e.g i sold my phone. and now new guy downloads the game and tries (facebook login) hell get error saying this id is already linked to a facebook account? how to avoid it if thats the case?

Sorry its a cluster so many question marks and questions. everything takes me back to square one. :'(

0 Likes 0 ·
Seth Du avatar image
Seth Du answered

For more effective discussions, we suggest that each thread we post only contains one or two questions. The additional questions can be asked in the related follow-up comments, which makes us concentrate on each one. It’s hard to start to answer all the questions but I will firstly explain the basic login mechanism for you. Here is an example.

  1. The player logins with Device ID_1 and then link with Facebook account_1. The result will be that a player creates an account (let’s call it PlayFab Account A) and link Device ID_1 and Facebook ID_1 to it.
  1. Pick up another phone, Login with Device ID_2 -> a new account is created (call it PlayFab Account B) and Device ID_2 is linked to it. Then try to call LinkFacebookAccount with the same Access token, Error will reported because this Access Token has been used for PlayFab Account A.
  1. Still in another phone, the user generates a new token(But it is still from Facebook ID_1), then call LinkFacebookAccount using that token, Error will still be report because Facebook ID_1 is linked to PlayFab Account A.
  1. The User generate another access token from Facebook ID_2. Currently he is logged in with PlayFab Account B, while he calls LinkFacebookAccount with this token. Success will be returned and Facebook ID_2 is linked with PlayFab Account B

The usage of Facebook login(the login mechanism of other platforms are similar) is:

  • Once a PlayFab player account is linked with Facebook account, unless the player calls API UnlinkFacebookAccount, other players cannot link that Facebook account to other PlayFab player account. LoginWithFacebook will always login into the same account.
  • UnlinkFacebookAccount is only available in Client API. Another way to remove Facebook account is directly using Game Manger.
  • To refresh the Facebook Access token, firstly you have to get the new token from Facebook side, then directly call LoginWithFacebook with the new token in the request. If you have logged in via other identities like device ID, you can call LinkFacebookAccount to refresh it. (the benefit is that you won’t change the PlayFab side’s session ticket)

If you still have questions about login, please tell me by pointing out which part that I described unclearly. For additional questions, please reply this post but please add one or two questions per time.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Talha avatar image Talha commented ·

Hi, Yeah i was a bit stressed out that why I just wrote down everything that popped in me head. Sorry

  1. "Still in another phone, the user generates a new token(But it is still from Facebook ID_1), then call LinkFacebookAccount using that token, Error will still be report because Facebook ID_1 is linked to PlayFab Account A".

okay i got it till here.

  1. "The User generate another access token from Facebook ID_2. Currently he is logged in with PlayFab Account B, while he calls LinkFacebookAccount with this token. Success will be returned and Facebook ID_2 is linked with PlayFab Account B".

If I got this right. so far (using this particular example) we cant link 2 devices to single facebook account by using LinkFacebookAccount.

Q1) How to do that? link two different devices to the same facebook id? so that both phones have the same account on them.(i.e i have two phones on which I would like to install the game)

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Talha commented ·
  • A PlayFab account is possible to link multiple accounts as you can see in the [game manager]->[Players Tab]->[Select a player], you are free to add more identities:

And this action is exactly the same as calling LinkAndroidDeviceID or LinkIOSDeviceID after you log in.

  • But in the previous scenario I have described, I didn't link 2 device ID to a single Facebook account. First you should know that all the identities and 3rd platform accounts are only the identity for PlayFab Account, which means the basic account is from PlayFab, and they are not linking each other, instead, they only links to PlayFab Account.
0 Likes 0 ·
Talha avatar image
Talha answered

Okay. I've got it now. Thankyou.

  • "To refresh the Facebook Access token, firstly you have to get the new token from Facebook side, then directly call LoginWithFacebook with the new token in the request. If you have logged in via other identities like device ID, you can call LinkFacebookAccount to refresh it. (the benefit is that you won’t change the PlayFab side’s session ticket)"

Okay so how do we do this?

right now i have two GameObjects in my unity game. FbManager and PFManager(both singleton).FbManager has all the necessary fb things and in PFManager all the playfab things.

we get the accesstoken in onFacebookLoggedIn function and then pass it to PFManager and then use it in PFManager class(to login and stuff).

now i have one question.

How to make it(facebook) frictionless? like it should happen automatically. even if the user doesnt open the app for a week. i have a general idea on how to do it but it would be great help if you could direct us.

4 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

I am not expertise in Facebook , but there should be long-term-use Facebook Access Token. PlayFab side can achieve silent login easily and if you are looking for getting a Facebook Access Token silently, you may ask for dedicated and professional help from Facebook Developer Community.

0 Likes 0 ·
Talha avatar image Talha Seth Du ♦ commented ·

can we link two different android devices with same facebook account? e.g tablet and mobile?

0 Likes 0 ·
Talha avatar image Talha Talha commented ·

by using loginwithAndroidID

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.