question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OAuth id_token missing information on refresh

See original GitHub issue

I’ve run into an interesting issue (bug?) with Google OAuth/OpenID Connect authentication. While it’s not directly an issue with this project, I think it’s the best place to report it since it has all the related authentication code, which in turn may cause confusion if other people use the authentication code in this project the same way I am. If there’s a better place to report this, please let me know.

My app is a desktop app using the localhost loopback method to receive the authentication code returned from the browser to obtain tokens.

Starting from the beginning, the app launches https://accounts.google.com/o/oauth2/v2/auth with these query strings:

client_id
redirect_uri=http://localhost:13604/
response_type=code
scope=email openid profile
state
code_challenge_method=S256
code_challenge
login_hint

That works fine, so I get a token using https://www.googleapis.com/oauth2/v4/token:

code
redirect_uri=http://localhost:13604/
code_verifier
client_id
client_secret
grant_type=authorization_code

Since I provided OpenID scopes, I get an id_token in the response. Looking at the token data, here’s what’s inside: 1

That all looks good.

Using the refresh_token we got back with id_token, I refresh using https://www.googleapis.com/oauth2/v4/token:

refresh_token
client_id
client_secret
grant_type=refresh_token

I get this id_token back: 2

Compare both id_token screenshots. The second one from the refresh is missing most of the identifying information. It appears there is a glitch with Google servers that makes it lose track of the scopes that were specified during the first authorization request. I wasn’t able to figure out a way to reclarify these scopes during the refresh request, which makes sense from a security standpoint, but also reinforces the fact that this may indeed be a server glitch.

This is a significant issue with the seamless login I had in mind. The only workaround right now is to ditch refreshing the token and to go through the full authentication each time. Hopefully the glitch can be addressed by relaying this information to the right person, or another workaround suggested.

Happy new year!🎉

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20

github_iconTop GitHub Comments

2reactions
jskeetcommented, Jan 23, 2018

I’ll start asking internally tomorrow - will see where that leads.

1reaction
jskeetcommented, Feb 3, 2018

I would suggest that it wouldn’t be random, but that the team is unlikely to want to make any guarantees about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Missing id_token when refreshing tokens?
and I do get a refresh token when I perform the code exchange. However, performing a refresh token request just yields an access_token...
Read more >
id_token missing in refresh_token response?
Describes how refresh tokens work to allow the application to ask Auth0 to issue a new access token or ID token without having...
Read more >
Not receiving Google OAuth refresh token
Surprisely this worked: delete the credentials.json, refresh, vinculate your app in your account again. The new credentials.json file will have ...
Read more >
OAuth access and refresh tokens are missing from my ...
Ensure that the access tokens and refresh tokens are enabled for your application. Also, verify that the token lifetimes are set appropriately ...
Read more >
Solutions for common OAuth2-related problems
Solutions for common OAuth2-related problems · OpenID Connect ID Token missing​ · OAuth 2.0 Refresh Token is missing​ · OAuth 2.0 authorize code ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found