-
Notifications
You must be signed in to change notification settings - Fork 69
fix(api): fix google refresh token issue #114
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ export interface UriParams { | |
redirect_uri: string; | ||
state: string; | ||
access_type?: string; | ||
prompt?: string; | ||
} | ||
|
||
export interface AuthCodeUriParams { | ||
|
@@ -75,10 +76,6 @@ export class OAuth2DefaultImpl implements OAuth2 { | |
params.scope = this.scopes; | ||
} | ||
|
||
if (this.providerName === "google") { | ||
params.access_type = "offline"; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is only necessary when creating the uri |
||
const accessToken = await client.getToken(params); | ||
|
||
return JSON.stringify(accessToken); | ||
|
@@ -98,6 +95,7 @@ export class OAuth2DefaultImpl implements OAuth2 { | |
|
||
if (this.providerName === "google") { | ||
uriParams.access_type = "offline"; | ||
uriParams.prompt = "consent"; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By adding this we will prompt the user to grant access to permissions every time they authenticate with google. This means if a user authenticates with multiple accounts they will have to grant permssions to their google account every time. Because they grant permissions we will receive a refresh token every time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 🎉 🎉 |
||
|
||
const authorizationUri = client.authorizeURL(uriParams); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the logic for having multiple accounts using the same google account if one gets revoked they all do. The problem is it will only remove the token from the provider map for the account that revoked access but all other accounts will still contain the token. Then when they fetch data google will throw a 401.
So for now we can just remove it locally from the providermap like we do for other providers and i think it should be fine but im open to feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me