-
Notifications
You must be signed in to change notification settings - Fork 988
fix chrome drive sync issues #252
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
Conversation
mymindstorm
commented
Dec 4, 2018
- Fixes issue with text not being substituted
- Fixes issue where failure message shows up instead of auth_revoke message
@Sneezry is this okay to merge? |
const res = JSON.parse(xhr.responseText); | ||
if (res.error) { | ||
if (res.error.code === 401) { | ||
if (navigator.userAgent.indexOf('Chrome') !== -1) { |
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.
can this line be removed?
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.
No. We have to handle Chrome Google account login differently (via chrome.identity
) from Firefox because of Google API restrictions. chrome.identity
isn't part of Firefox, hence the check here.
When a user revokes a token from Google's side the token is still cached in Chrome. So, if a user tries to sign in again directly after revoking a token chrome.identity.getAuthToken
would notice a cached token is still available and pull it even though it was revoked. This causes the extension to show a 'Failure' message since the 'new' token is revoked already.
To reproduce with 5.2.2:
- login to google drive
- sync
- revoke access from https://myaccount.google.com/permissions
- keep syncing until the extension gets a 401
- close and open the extension popup (not chrome)
- try to login again
- get error
- goto 6
To prove it's the cache after reproducing:
- see error after trying to login
- open chrome://identity-internals/ and revoke token
- try to login to drive sync
- success