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

UserRefreshClient constructor should set credentials.refresh_token #770

Closed
MaksimKiselev opened this issue Aug 1, 2019 · 3 comments · Fixed by #881
Closed

UserRefreshClient constructor should set credentials.refresh_token #770

MaksimKiselev opened this issue Aug 1, 2019 · 3 comments · Fixed by #881
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@MaksimKiselev
Copy link

When I create UserRefreshClient by constructor, I've get error:

Error: No access, refresh token or API key is set.

But when I load credentials by calling fromJSON method, all works correctly.

I looked at source code and find difference between this two ways:
fromJSON method set credentials.refresh_token property, but constructor don't:
https://github.com/googleapis/google-auth-library-nodejs/blob/v5.1.1/src/auth/refreshclient.ts#L111

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Aug 2, 2019
@bcoe bcoe added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Aug 12, 2019
@bcoe
Copy link
Contributor

bcoe commented Aug 12, 2019

@MaksimKiselev thanks for the bug report 👍 sounds like you have a work around for the time being?

@MaksimKiselev
Copy link
Author

@bcoe yes:

const client = new BigQuery({
  projectId
})

const credentials = {
  type: 'authorized_user',
  client_id: clientId,
  client_secret: clientSecret,
  access_token: acessToken,
  refresh_token: refreshToken
}

const refreshClient = new UserRefreshClient()
refreshClient.fromJSON(credentials)

client.authClient.cachedCredential = refreshClient

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jan 28, 2020
bcoe added a commit that referenced this issue Jan 28, 2020
@bcoe bcoe closed this as completed in #881 Jan 28, 2020
@bcoe
Copy link
Contributor

bcoe commented Jan 28, 2020

@MaksimKiselev just landed a fix, please note that you should provide refresh_token to the constructor as refreshToken, access_token as accessToken, etc.

Thank you for the bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants