Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gapi.auth.getToken() returns null after unsuccessful auth, even if we had a previous successful auth #109

Open
rileylark opened this issue Sep 17, 2015 · 1 comment

Comments

@rileylark
Copy link

My app practices incremental permissions, so first we ask you for X, and then if we need Y later we ask you for Y later.

But, if you deny us Y, the gapi client loses the token for X.

We could save the previous token and manually restore it on auth failure, but then of course we get race conditions. I'd like an easy way to aggregate permissions in the client token, so I could call

authorize({immediate: true, scope: 'X'});
authorize({immediate: true, scope: 'Y'});
authorize({immediate: true, scope: 'Z'});

and be relatively confident that at the end I'll end up with a token that represents the available permissions (for example, maybe I end up with X and Z).

I could write a wrapper to authorize that does some traffic control, makes sure only one authorize request is in flight at a time, manages the conflict resolution (while staying timeout-aware), etc etc etc.. but it seems like it might be within the scope of gapi.auth.authorize to handle all of this for me.

Let me know if there's a better place to post an issue like this. Thanks for any advice!

@rileylark
Copy link
Author

To clarify a bit, I do know about include_granted_scopes and that behavior is working great. But the problem I'm facing is that if the user has NOT granted the scope for Y in my example, and the authorization attempt fails, then I lose my token altogether! Because Y returns a rejection, the client forgets all about the fact that it actually has access to X and Z.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant