How do you use Google API getRequestHeaders() to get an OAuth2 access token?

derefed

I'm using the googleapis npm library to authorize using OAuth2 to access my Gmail account to send emails. I am using the following code (TypeScript) to do that:

const oAuth2Client = new google.auth.OAuth2(
  googleConfig.clientId,
  googleConfig.clientSecret
);

oAuth2Client.setCredentials({
  refresh_token: googleConfig.refreshToken
});

const accessTokenRetVal = (await oAuth2Client.refreshAccessToken()).credentials.access_token;
const accessToken = accessTokenRetVal || '';

This code works, but I get the following message:

(node:8676) [google-auth-library:DEP007] DeprecationWarning: The `refreshAccessToken` method has been deprecated, and will be removed in the 3.0 release of google-auth-library. Please use the `getRequestHeaders` method instead.

I have searched on Google, on the GitHub for the googleapis module, on StackOverflow, and I haven't been able to find any documentation for what constitutes the getRequestHeaders method. I've tried calling getRequestHeaders, but it doesn't appear to return a credentials object with an access token.

Are there official docs for how getRequestHeaders should be used in this situation?

Joe Kurian

const accessToken=oAuth2Client.getAccessToken()

This worked for me

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I get an oauth2 access_token using Python

分類Dev

How to get new access token in OpenID Connect/OAuth2 Implicit Flow

分類Dev

web api 2 - Oauth2 Bearer token access is forbidden

分類Dev

How do I get access token using Google plus

分類Dev

google oauth2 get token javascript post request

分類Dev

OAuth2 access token

分類Dev

How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

分類Dev

How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

分類Dev

Google API getRequestHeaders()をどのように使用してOAuth2アクセストークンを取得しますか?

分類Dev

How do I use Google's token from AccountManager in my web app? (Rails with omniauth-google-oauth2)

分類Dev

Google OAuth2 api

分類Dev

Spring Boot Security OAuth2 Get Access_token from Cookie

分類Dev

Get Google Client API access token using CURL

分類Dev

how do you access a jenkins api which uses Github OAuth using CURL

分類Dev

How to generate Facebook Marketing API access token to use it in Windows application

分類Dev

How to get the access token from Linkedin API with express and axios?

分類Dev

How do you access a Google Sheet with a service account from Java?

分類Dev

How to access the Uber API OAuth 2.0 bearer token in curl calls

分類Dev

API Authentication and use of OAuth2

分類Dev

OAuth2 security in REST GET API

分類Dev

Google Oauth2: Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }'

分類Dev

Error refreshing the OAuth2 token @ Google_CalendarServices (php)

分類Dev

Google oauth2 returns no id_token

分類Dev

Google Sheet API Access Token Getting Expired

分類Dev

Google androidpublish api access_token

分類Dev

Unable to get access token-Uber API

分類Dev

Get access token for web api using Jquery

分類Dev

How do you use TensorFlow Graphkeys to get all weights?

分類Dev

How to use Google public API access key in android application?

Related 関連記事

  1. 1

    How can I get an oauth2 access_token using Python

  2. 2

    How to get new access token in OpenID Connect/OAuth2 Implicit Flow

  3. 3

    web api 2 - Oauth2 Bearer token access is forbidden

  4. 4

    How do I get access token using Google plus

  5. 5

    google oauth2 get token javascript post request

  6. 6

    OAuth2 access token

  7. 7

    How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

  8. 8

    How to use Spring Security 5 and OAuth2 Client to get refresh tokens and make API calls?

  9. 9

    Google API getRequestHeaders()をどのように使用してOAuth2アクセストークンを取得しますか?

  10. 10

    How do I use Google's token from AccountManager in my web app? (Rails with omniauth-google-oauth2)

  11. 11

    Google OAuth2 api

  12. 12

    Spring Boot Security OAuth2 Get Access_token from Cookie

  13. 13

    Get Google Client API access token using CURL

  14. 14

    how do you access a jenkins api which uses Github OAuth using CURL

  15. 15

    How to generate Facebook Marketing API access token to use it in Windows application

  16. 16

    How to get the access token from Linkedin API with express and axios?

  17. 17

    How do you access a Google Sheet with a service account from Java?

  18. 18

    How to access the Uber API OAuth 2.0 bearer token in curl calls

  19. 19

    API Authentication and use of OAuth2

  20. 20

    OAuth2 security in REST GET API

  21. 21

    Google Oauth2: Error refreshing the OAuth2 token, message: '{ "error" : "invalid_grant" }'

  22. 22

    Error refreshing the OAuth2 token @ Google_CalendarServices (php)

  23. 23

    Google oauth2 returns no id_token

  24. 24

    Google Sheet API Access Token Getting Expired

  25. 25

    Google androidpublish api access_token

  26. 26

    Unable to get access token-Uber API

  27. 27

    Get access token for web api using Jquery

  28. 28

    How do you use TensorFlow Graphkeys to get all weights?

  29. 29

    How to use Google public API access key in android application?

ホットタグ

アーカイブ