google / google/googleapis.dart
Assertion failure when access token reponse does not include refresh token
- Dominant language
- Dart
- Stars
- 419
- Forks
- 136
- Avg merge
- 1h 21m
- Merged PRs (30d)
- 5
Description
In `oauth2_flows/auth_code.dart`, the function `obtainAccessCredentialsViaCodeExchange()` sends an OAuth2 token request, obtaining an access token as JSON, of the form:
```
0: "access_token" -> ""
1: "expires_in" -> 3487
2: "scope" -> "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email"
3: "token_type" -> "Bearer"
4: "id_token" -> ""
```
This is returned and stored in `credentials` in `endpoints/google_endpoint.dart:230`. Then an `AutoRefreshingClient` is instantiated using these credentials. That causes an assert failure in `auth_http_utils.dart:98`:
```
assert(credentials.refreshToken != null),
```
The access token JSON does not include `refresh_token` (which would be saved in `credentials` as `refreshToken` by `auth_code.dart:128`).
This causes Google login to fail.
I don't know why the response does not include a refresh token in this case, but wouldn't it be better to still enable temporary login even if a refresh token is not provided by the server?
Contributor guide
Assessment
This issue has not been assessed yet.