question

brendan avatar image
brendan asked

190 BadRequest on calls to GetFriendsList or GetFriendLeaderboard

Question from a developer:

I'm getting a 190 BadRequest (or OAuthException) back in the details of an error response on a call to get the friends list or a friend leaderboard for one of my players. What can cause this?

10 |1200

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

brendan avatar image
brendan answered

Ah, interesting! I was assuming you were using LoginWithFacebook to update the token. In general, the expectation is that you would use the Link calls to set associations for accounts, then log the player in using the Login calls. In reviewing the code, I do see that the Link logic simply returns an OK if the token submitted is for the Facebook account already linked to the PlayFab user account, but it doesn't update to that new token - I'll open a bug to get that changed, so that it does. In the meantime, you can fix this fairly easily by using the Login call, instead of the Link call in your flow.

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.

Dean Loades avatar image Dean Loades commented ·

That's great! Thanks!

Just to clarify @Brendan, the reason I am using Link, instead of just Login, is that in the case of someone who hasn't logged in with FB before, I assume calling LoginWithFacebook will create a new player for them (they are already logged in as a guest). So for every player who logs in with facebook, we end up with 2 accounts. One of which is probably not going to be used again.

On the other hand calling Link, leaves them with the same account, and doesn't waste the guest account.

So I am basically doing it so that I don't waste your servers.

0 Likes 0 ·
brendan avatar image brendan Dean Loades commented ·

You should use Link to attack the Facebook credentials to the account, yes. But the only way the Login call would create a new account is if you have CreateAccount set to true.

0 Likes 0 ·
Dean Loades avatar image Dean Loades brendan commented ·

I need create account to be true because at this stage there is no way to know if they are linked already. Unless I go and get account info.

So any of these these would fix my problem. (in order of preference)

1) LinktoFacebook updates to the new token.

2) LoginResult tells me which accounts are connected

3) Result from Link tells me that it is already linked. Not ideal.

4) I just call Login if I get a 190. Pretty dirty.

0 Likes 0 ·
Show more comments
brendan avatar image
brendan answered

The 190 error is coming back from Facebook. Basically, any call that requires us to get info from Facebook on the user's behalf requires a valid Facebook token. The token the client gets from Facebook is a short term token, meaning it's only valid for an hour or so (and Facebook could change that at any time, so don't count on it). We do have a backlog item for us to convert that to a long term token if the title has the Facebook app secret key configured in our service (required, for us to get the long term token), and we'll be addressing that later this year. But even with that, the Facebook token could expire or be revoked at any time, so this is a condition you need to watch out for. If you get this error, the way to handle it is to re-authenticate the player, using a Facebook token (LoginWithFacebook), so that our service can continue to make calls on the user's behalf.

10 |1200

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

fabian-kuhn@gmx.de avatar image
fabian-kuhn@gmx.de answered

So if i understand that right, if GetFriendsList for example fires the error delegate with the errorCode 190, u should call LoginWithFacebook from the FB SDK and retry GetFriendsList ?

Best regards

10 |1200

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

brendan avatar image
brendan answered

Yes, if you get the 190 BadRequest return, the thing to do is to sign back in with LoginWithFacebook (using any of our SDKs, or a direct call to our Web API), passing in a fresh auth ticket from Facebook. Then, you can re-try the call that failed.

10 |1200

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

fabian-kuhn@gmx.de avatar image
fabian-kuhn@gmx.de answered

As a title who only uses the Facebook token for the GetFriendList and GetLeaderBoard calls, i should unlink my old facebook token and relink the new one ,since i dont call LoginWithFacebook ?

10 |1200

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

brendan avatar image
brendan answered

I would recommend just linking the Facebook account once, and then using LoginWithFacebook, since that'll be faster for you. If you call unlink/link, you have to wait on two roundtrips instead of one, and you need the same token for either the login or link call anyway.

10 |1200

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

fabian-kuhn@gmx.de avatar image
fabian-kuhn@gmx.de answered

That confuses me.

In my title Facebook is optional, so i use LoginWithAndroidID for example to login.

Lets use that example:

Player A creates an Account, after that, he connects to Facebook and uses LinkFacebookAccount. Now he can use GetFriendsList and can get his Facebook friends.

He does the call and gets Error 190. Now i relogin with the Facebook SDK and get a NEW facebook token. When i use LoginWithFacebook and pass the new token, a new account will be created since that facebook token is not in use ? So i have to unlink the old token and relink the new one to the same playfabid, no ?

10 |1200

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

brendan avatar image
brendan answered

No, once a Facebook account has been linked to the player's account, any sign-in using a token for that Facebook account (specifically for that application) will result in using the existing PlayFab account. The Facebook token is not unique to the user - it is unique to the user + application + time period. So the same user on the same application would get a different token in an hour, but the resulting Facebook ID for that user on that application would always be the same. And that's what we use to get you to the right account.

That's actually one of the reasons we're specifically saying you should not unlink the account then re-link it. If your player loses connectivity (driving into a tunnel, etc.) after the unlink call, that Facebook account is no longer linked to a PlayFab account. If you were to use LoginWithFacebook at that point (with CreateAccount set to true), you would create a new PlayFab account, but only because you unlinked the Facebook account from the PlayFab account.

10 |1200

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

Dean Loades avatar image
Dean Loades answered

@Brendan I am getting this error just after linking to facebook.

This is my theory on why. Would be good if you could say if this could be what is going down.

I have a guest login, and then I do a fresh login to Facebook. On success it then links to facebook with that token. Then it is doing more calls and getting the 190 Bad Request.

So I think what is happening is that Playfab is saying Already Linked (which is true) and proceeding to ignore the fresh token that I just sent. It then continues to use the last one it got, which is stale.

Does that sound about right? If so, can you think of a better way to go about this? Or a way around it?

It would be great if the LoginResult told you what the account was linked to.

Thanks!

10 |1200

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

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.