Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by fknauer · Jun 19, 2017 at 07:11 PM · Authentication

Authenticate with GooglePlay Services: Login works, Link does not

Setup:

Unity 5.6.1.p4

play-games-plugin-for-unity: v0.9.39a

PlayFabSdk: 2.23.170612

I am able to authenticate with GooglePlay Services and can obtain a ServerAuthCode.

My fist login flow is like this:

I try to login with LoginWithGoogleAccountRequest but dont create an account with it. If the user does not have an accout assigned with GooglePlay I create a account with LoginWithCustomID and save it locally.

When the LoginWithCustomID is successful i try to link the GooglePlay account of the user with LinkGoogleAccount but the link request always returns with "InvalidGoogleToken".

I thought i got something messed up with the ServerAuthCode but then i try to with create account with LoginWithGoogleAccountRequest the ServerAuthCode is valid and the request successful.

I want to keep the CustomId as a default to not be dependent on the availability of google play and use it as a local fallback.

Any idea what could cause the InvalidGoogleToken with LinkGoogleAccount?

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Jun 20, 2017 at 12:22 AM

I take it you're attempting to re-use the Server Auth Code you used in the call to LoginWithGoogleAccount in your flow? The problem is that when you called login, we used that code to get a token from Google. Attempting to re-query for a token using the same code is likely resulting in an error. Could you try getting a fresh auth code, and trying to link with it? Under the covers, just so you know, it's literally the same function call on our side to validate the code and get a token, whether it's for a login or a link operation.

Comment

People who like this

0 Show 6 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fknauer · Jun 20, 2017 at 08:48 AM 0
Share

Thanks for the quick answer. Yes I am using the same Server Auth Code for both calls. I was not aware that the code gets invalid after using it once. The official play games plugin from google is caching the Server Auth Code for the whole session so I have to re authenticate the user to get a fresh code.

avatar image Brendan ♦♦ fknauer · Jun 20, 2017 at 08:49 AM 0
Share

It's not that it's invalidated, but an attempt to get a token from it will return an error after the first try - it can still be used for a refresh token, but that would be for after the first sign-in.

avatar image fknauer · Jun 20, 2017 at 03:50 PM 0
Share

Are you sure that this is the intended behavior? I want to be able that the user can switch between different PlayFab accounts with different google accounts. So when i try to link the google account after the user connected to google play and the account is already claimed i ask the user if he wants to login with the other account. currently i would have to reconnect google play because i "used" the current ServerAuthCode already. Theoretically it should be possible to use the ServerAuthCode several times until its revoked.

avatar image Brendan ♦♦ fknauer · Jun 20, 2017 at 08:49 PM 0
Share

I can't really speak to Google's intent, but simply put, when you get the InvalidGoogleToken response, that's specifically because we tried to use the ServerAuthCode to get a Token, and Google returned either invalid_token, invalid_client, or invalid_grant. In the case of re-using a ServerAuthCode, the indication is that they return invalid_grant.

avatar image fknauer · Jun 20, 2017 at 09:15 PM 0
Share

Thanks for the clarification. My solution is to ask the user to re authenticate if the token is invalid. This only happens in rare cases when the user switches accounts manually.

avatar image Ben fknauer · Jun 15, 2020 at 06:51 AM 0
Share

hello @fknauer can you tell me how to do a reauthenticate? thanks

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    4 People are following this question.

    avatar image avatar image avatar image avatar image

    Related Questions

    Do REST API sessions time out? 9 Answers

    Link Google Account only partially works 1 Answer

    Unlink custom id on password reset 1 Answer

    Custom Server authentication flow for analytics 1 Answer

    Get Language List fails at Entity Authentication 2 Answers

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges