Skip to content

[QUESTION] Token refresh on Google service returns 'Bad Request' #419

@geekarist

Description

@geekarist

I'm trying to use AuthState.performActionWithFreshTokens() to call a Google web service when my auth token has expired.

It seems that AuthState.performActionWithFreshTokens() uses the scope of the latest auth response and sends it to https://www.googleapis.com/oauth2/v4/token.

So when I do that, I get a Bad Request from v4/token because in the case of a token refresh, it doesn't expect a scope, as the documentation mentions: https://developers.google.com/identity/protocols/OAuth2InstalledApp#offline

I have tried to work around this by clearing the scope that is used by performActionWithFreshTokens() before refreshing my auth token, but the field is private so I can't override AuthState for this. Here is the code of my app: https://github.com/geekarist/who-am-i/blob/cdd5cf9cdfff02de02b6e8a467ea98e36e834a94/app/src/main/java/me/cpele/whoami/ProfileViewModel.kt#L31

Is there any other way?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions