8000 fix(api): fix google refresh token issue by Orta21 · Pull Request #114 · metriport/metriport · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Feb 22, 2023
Merged

Conversation

Orta21
Copy link
Member
@Orta21 Orta21 commented Feb 22, 2023

Ref. metriport/metriport-internal#177

Ref: 177

Dependencies

None

Description

Fixed the google refresh token issue by prompting user to always grant permissions when authenticating

Release Plan

ASAP

@Orta21 Orta21 requested review from leite08 and Goncharo February 22, 2023 14:07
if (this.providerName === "google") {
params.access_type = "offline";
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only necessary when creating the uri

@@ -98,6 +95,7 @@ export class OAuth2DefaultImpl implements OAuth2 {

if (this.providerName === "google") {
uriParams.access_type = "offline";
uriParams.prompt = "consent";
}
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉

await this.oauth.revokeLocal(connectedUser);
} catch (error) {
throw new Error("Google Revoke failed");
}
}

Copy link
Member Author
@Orta21 Orta21 Feb 22, 2023

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.

Copy link
Member

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

Copy link
Member
@Goncharo Goncharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to take out the commented out code and 🚢 🚢 🚢

@@ -98,6 +95,7 @@ export class OAuth2DefaultImpl implements OAuth2 {

if (this.providerName === "google") {
uriParams.access_type = "offline";
uriParams.prompt = "consent";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉

await this.oauth.revokeLocal(connectedUser);
} catch (error) {
throw new Error("Google Revoke failed");
}
}

Copy link
Member

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

@Orta21 Orta21 merged commit 17ea8f6 into develop Feb 22, 2023
@Orta21 Orta21 deleted the fix-google-refresh-token branch February 22, 2023 19:51
@github-actions
Copy link

🎉 This PR is included in version 1.4.0-develop.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 2.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants
0