Open Nfinished opened 4 years ago
Sure, sounds good to me
Excellent! Here's what I'm thinking..
useGoogleLogin could export a new property addScope
with signature string => undefined
It'd also accept new options onAddScopeRequest, onAddScopeSuccess, onAddScopeFailure
to support it.
addScope
would only run if a) gapi has been loaded, and b) the user is logged in, meaning isSignedIn
would have to be passed in through options for it to be accessible.
Alternative to b), addScope
could dispatch to signIn
with its extra scopes that'd then be concatted on to the initial call, but that feels like an antipattern.
This feels like the safest option to me since we'll always be able to rely on gapi and the user being in a good state before addScope
is run.
Main caveat is even more responsibility on useGoogleLogin, but barring some kind of provider that configures gapi instead of useGoogleLogin's useEffect, it beats repeating the initialization check or reinitializing in a different hook.
Thoughts?
Think "a" sounds like a good option to try.
Hello! Would you accept a PR for incrementally adding scopes to a session as outlined here?
https://developers.google.com/identity/sign-in/web/incremental-auth