How to use OAuth2 with node.js

后端 未结 1 1543
抹茶落季
抹茶落季 2021-01-28 06:30

I would like to use @google-cloud client lib to insert data to BigQuery.
Since I have multiple clients and each has different IAM role I can\'t use a service account like th

相关标签:
1条回答
  • 2021-01-28 07:30

    The JSON object you shared is not an OAuth token, it looks like a OAuth2Client object from @google-auth-library.

    An actual OAuth token is simply a string, like "ya29.ABC123ABC123_cG123ABCDETCETCETC".

    That "token" is actually an OAuth2Client then you can fetch the token with the getAccessToken method. If it is just a plain JSON object, then you can get the credentials.access_token field, is the actual access token.

    Note that access tokens expire. getAccessToken will get a new one if necessary, but just getting the access_token from the object will not, and can result in 403s after it expires.

    0 讨论(0)
提交回复
热议问题