AuthToken from AccountManager in Android Client No Longer Working

前端 未结 2 1520
旧巷少年郎
旧巷少年郎 2020-12-07 08:56

I\'m pretty exasperated. I\'m attempting to build a turn-based multiplayer online game for Android using Google App Engine in Java as the server.

They seem like a pe

2条回答
  •  执念已碎
    2020-12-07 09:58

    Got help for this from a Google engineer. Turns out my authToken was expired. I had initially gotten the implementation working in early December (the 9th to be exact). Apparently what the AccountManager does is cache the authToken, so I had been using the same authToken since Dec. 9th. When I got back from the holidays it had expired.

    To solve the issue, I now call getAuthToken, then call invalidateAuthToken on that token, then call getAuthToken again. This generates a valid authToken and works just fine, even if it is a little clunky and would be unnecessary if AccountManager just got a fresh authToken each time, or did a check to see if the cached one was expired.

    Note that you must not mix up token type with account type: invalidateAuthToken must be called with "com.google" instead of "ah" or it will silently fail.

提交回复
热议问题