Skip to content
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

"Unauthorized" error when credentials expire #94

Closed
nolanmar511 opened this issue Dec 19, 2017 · 9 comments · Fixed by googleapis/google-auth-library-nodejs#242
Closed
Assignees
Labels
api: cloudprofiler Issues related to the googleapis/cloud-profiler-nodejs API. 🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@nolanmar511
Copy link
Contributor

The call to the request to create a profile can hang for up to an hour. If the credentials expire while this request is hanging, then an 'Unauthorized' error is returned.

To reduce the frequency of this error, we want to refresh the token before it has expired when making requests.

@nigon1
Copy link

nigon1 commented Dec 22, 2017

on issue

@nolanmar511
Copy link
Contributor Author

Added the ability to refresh before the token expires to google-auth-library-nodejs.
Still need to modify @google-cloud/common (repository here) and google-auto-auth (repository here).

The change to google-auth-library has not yet been published to npm.

@aalexand
Copy link
Contributor

aalexand commented Mar 6, 2018

@nolanmar511 Please update with the status.

@nolanmar511
Copy link
Contributor Author

We are using google-auth-library 1.3.1 for development (based on our package-lock.json), so the token will be refreshed 5 minutes before it expires (rather than once it has expired). This should reduce the probability of these errors
However, it is my understanding that if a token expires during a request, google-auth-library does not refresh the token and retry, so we may still see unauthorized errors.

@JustinBeckwith
Copy link
Contributor

Of course we do! If the request fails with a 401 or 403, under many conditions we will try to refresh the token. We are changing some of this behavior in 2.0 to only retry if a refresh_token is present. Check this out:
https://github.com/google/google-auth-library-nodejs/blob/master/src/auth/oauth2client.ts#L696

If there's another place you want retry logic, please do let me know!

@nolanmar511
Copy link
Contributor Author

@JustinBeckwith -- Thanks! Is this logic new with 1.0? Prior to upgrading to 1.0, we'd seen the "Unauthorized" Error in our code.

@JustinBeckwith
Copy link
Contributor

Nope, this has been around for a while. I think the code you added to add a higher expiry window likely cleaned a lot of these up.

@ofrobots
Copy link
Contributor

ofrobots commented May 1, 2018

@nolanmar511 can you check if this is still an issue?

@nolanmar511
Copy link
Contributor Author

Marking this as closed.
Ran 20 programs with matching deployment labels for 3 hours. The "Unauthorized" error did not appear in the output from these.

@google-cloud-label-sync google-cloud-label-sync bot added the api: cloudprofiler Issues related to the googleapis/cloud-profiler-nodejs API. label Jan 31, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: cloudprofiler Issues related to the googleapis/cloud-profiler-nodejs API. 🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
6 participants