New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 763506 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 1
Type: Bug



Sign in to add a comment

TokenService: Refresh token does not become available

Project Member Reported by khorimoto@chromium.org, Sep 8 2017

Issue description

Getting an issue in which we cannot fetch a refresh token.

During Tether initialization, we call ProfileOAuth2TokenService::RefreshTokenIsAvailable(). If the token is not available, we observer the service and wait for it to become available. However, sometimes this never occurs until the user connects to the Internet.

Any reason why this would be the case?

Our code: https://cs.chromium.org/chromium/src/chromeos/components/tether/initializer_impl.cc?q=token_service_
 
My guess is that RefreshTokenIsAvailable() does not return true unless you are online. 

If that is the case (looking at the code to confirm this), why would Instant Tether be depended on presence of the refresh token? You can't do anything with the token while you are offline anyway.  
Owner: khorimoto@chromium.org
Status: Started (was: Untriaged)
It does work offline most of the time (I've never run into this issue before).

That being said, I don't understand why this would be necessary anyway. I'm going to try removing this check and see if things still work. hansberry@ doesn't remember the exact reason why it was added originally.

Comment 3 by msarda@chromium.org, Sep 11 2017

The token service does not depend on network for loading refresh tokens, so I expect there is a different problem here.

BTW, I think in this code you are missing an observer for OnRefreshTokenAvailable:
https://cs.chromium.org/chromium/src/google_apis/gaia/oauth2_token_service.h?rcl=124d0939677878ff9f5626e07396457fc36a156d&l=102

This means that is the user reautenticates signs in while thethering is running, you will miss the call for a new refresh token

I suggest you do the following things:
1. With the current logs, it is hard to say if OnRefreshTokensLoaded was not called or if cryptauth_service_->GetAccountId() returns an account that is not correct. It would make sense to move the log at the beginning of the function OnRefreshTokensLoaded (here https://cs.chromium.org/chromium/src/chromeos/components/tether/initializer_impl.cc?rcl=da28029cf4834daf7e194c267786706e3ed612de&l=198).
2. On desktop, the refresh token may change at any time (if the user revokes the permissions and re-authenticates). I do not know whether this may happen on ChromeOS though. In any case, it may make sense to add an observer for OnRefreshTokenAvailable.
3. What if the tokens are loaded and the refresh token for the cryptauth account is not available (e.g. disk read error, decrypt error etc)?
4. What does it mean the comment at https://cs.chromium.org/chromium/src/chromeos/components/tether/initializer_impl.cc?rcl=21785d8584a4db46681b412eb5f6fece7a553dbd&l=193 ? How does it continue to wait for the token (what callback do you expect here)?

Labels: -Pri-2 ReleaseBlock-Stable Pri-1
Thanks for the feedback! I've actually looked more deeply into this code, and I'm not even sure why it was necessary in the first place. The place where we need the OAuth token should be in our CryptAuth code, not in the Tether component.

The CryptAuth code is located at [1], and it seems like we are already doing the right thing here by using OnRefreshTokensLoaded(). Can you confirm? Thank you!

[1] https://cs.chromium.org/chromium/src/chrome/browser/cryptauth/chrome_cryptauth_service.cc
Labels: Merge-Request-61 Merge-Request-62
Project Member

Comment 7 by bugdroid1@chromium.org, Sep 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a88ec4a641c0843466d9b1aa810f72b915ddc66a

commit a88ec4a641c0843466d9b1aa810f72b915ddc66a
Author: Kyle Horimoto <khorimoto@google.com>
Date: Wed Sep 13 00:40:27 2017

[CrOS Tether] Eliminate token fetch from Initializer.

This code was unnecessary, since the CryptAuth component is the one that
needs to listen for these tokens. Additionally, the listener in this
class was set up improperly, which made it possible to get "stuck"
without a token.

Bug:  763506 , 672263
Change-Id: I3e02f10aa201b129591028a8606b6fb4eefbaf11
Reviewed-on: https://chromium-review.googlesource.com/663978
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501486}
[modify] https://crrev.com/a88ec4a641c0843466d9b1aa810f72b915ddc66a/chrome/browser/chromeos/tether/tether_service.cc
[modify] https://crrev.com/a88ec4a641c0843466d9b1aa810f72b915ddc66a/chrome/browser/chromeos/tether/tether_service_unittest.cc
[modify] https://crrev.com/a88ec4a641c0843466d9b1aa810f72b915ddc66a/chromeos/components/tether/initializer_impl.cc
[modify] https://crrev.com/a88ec4a641c0843466d9b1aa810f72b915ddc66a/chromeos/components/tether/initializer_impl.h
[modify] https://crrev.com/a88ec4a641c0843466d9b1aa810f72b915ddc66a/chromeos/components/tether/initializer_impl_unittest.cc

Project Member

Comment 8 by sheriffbot@chromium.org, Sep 13 2017

Labels: -Merge-Request-61 Merge-Review-61 Hotlist-Merge-Review
This bug requires manual review: Request affecting a post-stable build
Please contact the milestone owner if you have questions.
Owners: amineer@(Android), cmasso@(iOS), ketakid@(ChromeOS), govind@(Desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Comment 9 by ketakid@google.com, Sep 13 2017

Labels: -Merge-Review-61 -Merge-Request-62 Merge-Approved-62 Merge-Approved-61
Approving merge to M61 and M62.
Status: Fixed (was: Started)
Project Member

Comment 11 by bugdroid1@chromium.org, Sep 13 2017

Labels: -merge-approved-62 merge-merged-3202
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/79da5a0a75e223db3bcd22f708ade258ae99157b

commit 79da5a0a75e223db3bcd22f708ade258ae99157b
Author: Kyle Horimoto <khorimoto@google.com>
Date: Wed Sep 13 01:49:48 2017

[CrOS Tether] Eliminate token fetch from Initializer.

This code was unnecessary, since the CryptAuth component is the one that
needs to listen for these tokens. Additionally, the listener in this
class was set up improperly, which made it possible to get "stuck"
without a token.

TBR=khorimoto@google.com

(cherry picked from commit a88ec4a641c0843466d9b1aa810f72b915ddc66a)

Bug:  763506 , 672263
Change-Id: I3e02f10aa201b129591028a8606b6fb4eefbaf11
Reviewed-on: https://chromium-review.googlesource.com/663978
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: Ryan Hansberry <hansberry@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#501486}
Reviewed-on: https://chromium-review.googlesource.com/663982
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/branch-heads/3202@{#193}
Cr-Branched-From: fa6a5d87adff761bc16afc5498c3f5944c1daa68-refs/heads/master@{#499098}
[modify] https://crrev.com/79da5a0a75e223db3bcd22f708ade258ae99157b/chrome/browser/chromeos/tether/tether_service.cc
[modify] https://crrev.com/79da5a0a75e223db3bcd22f708ade258ae99157b/chrome/browser/chromeos/tether/tether_service_unittest.cc
[modify] https://crrev.com/79da5a0a75e223db3bcd22f708ade258ae99157b/chromeos/components/tether/initializer_impl.cc
[modify] https://crrev.com/79da5a0a75e223db3bcd22f708ade258ae99157b/chromeos/components/tether/initializer_impl.h
[modify] https://crrev.com/79da5a0a75e223db3bcd22f708ade258ae99157b/chromeos/components/tether/initializer_impl_unittest.cc

Project Member

Comment 12 by bugdroid1@chromium.org, Sep 13 2017

Labels: -merge-approved-61 merge-merged-3163
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287

commit 2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287
Author: Kyle Horimoto <khorimoto@google.com>
Date: Wed Sep 13 01:50:56 2017

[CrOS Tether] Eliminate token fetch from Initializer.

This code was unnecessary, since the CryptAuth component is the one that
needs to listen for these tokens. Additionally, the listener in this
class was set up improperly, which made it possible to get "stuck"
without a token.

TBR=khorimoto@google.com

(cherry picked from commit a88ec4a641c0843466d9b1aa810f72b915ddc66a)

Bug:  763506 , 672263
Change-Id: I3e02f10aa201b129591028a8606b6fb4eefbaf11
Reviewed-on: https://chromium-review.googlesource.com/663978
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: Ryan Hansberry <hansberry@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#501486}
Reviewed-on: https://chromium-review.googlesource.com/663983
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/branch-heads/3163@{#1183}
Cr-Branched-From: ff259bab28b35d242e10186cd63af7ed404fae0d-refs/heads/master@{#488528}
[modify] https://crrev.com/2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287/chrome/browser/chromeos/tether/tether_service.cc
[modify] https://crrev.com/2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287/chrome/browser/chromeos/tether/tether_service_unittest.cc
[modify] https://crrev.com/2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287/chromeos/components/tether/initializer_impl.cc
[modify] https://crrev.com/2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287/chromeos/components/tether/initializer_impl.h
[modify] https://crrev.com/2dc9bc7e40b6d8992ce06f0b68610ff47b1f9287/chromeos/components/tether/initializer_impl_unittest.cc

Comment 13 by dchan@chromium.org, Jan 22 2018

Status: Archived (was: Fixed)

Comment 14 by dchan@chromium.org, Jan 23 2018

Status: Fixed (was: Archived)

Sign in to add a comment