-
Notifications
You must be signed in to change notification settings - Fork 383
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
Facing timeout issue for https://www.googleapis.com/oauth2/v4/token while generating oauth access token using google-auth-library #1786
Comments
This is currently tracked via: I should have some updates shortly to resolve this issue. |
Does it means my issue has been resolved ? |
Can you provide node js implementation of google-auth-library for oauth 2.0 access token generation ? |
google-auth-library-nodejs/src/auth/oauth2client.ts Lines 634 to 685 in b2eae07
|
error: FetchError: request to https://www.googleapis.com/oauth2/v1/certs failed, reason: connect ETIMEDOUT 142.251.43.10:443 |
error: FetchError: request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 142.251.43.10:443 |
I am using service-account.json credentials to generate a client and use that client to generate access token. Provide node js implementation for above scenario where instead of client id & secret we are using service-account.json credentials |
@danielbankhead any updates? |
This particular issue should be resolved as of 9.8.0+ with the following PR: Is anyone experiencing this issue in the latest release? |
I have created an nodejs api to generate oauth2 accessToken using google-auth-library for FCM HTTP V1 API.
This api generates an oauth2 accessToken which will then be used by my react app to make a request to FCM HTTP V1 API.
The api code works fine on my local machine gives the excepted output. But when this code is deployed on server I am facing timeout issue for https://www.googleapis.com/oauth2/v4/token this endpoint.
Code :-
module.exports.generateToken = async function (transactionId) {
try
{
const SCOPES = "https://www.googleapis.com/auth/firebase.messaging";
const currentTimeZone = new Date(Date.now());
currentTimeZone.setHours( currentTimeZone.getHours() + config.AccessTokenExpiryTime );
const auth = new GoogleAuth({
credentials: {
client_email: config.client_email,
private_key: config.private_key,
},
scopes: SCOPES,
});
}catch (error) {
loggerDetail.debug( transactionId + " Failed to retrieve access token: " + error.message );
}
};
####################### Error while token generation: GaxiosError: request to https://www.googleapis.com/oauth2/v4/token failed, reason: connect ETIMEDOUT 142.250.192.170:443
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at Gaxios._request (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/gaxios/build/src/gaxios.js:148:19)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at processTicksAndRejections (node:internal/process/task_queues:96:5)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async GoogleToken.requestToken (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/gtoken/build/src/index.js:230:23)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async GoogleToken.getTokenAsync (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/gtoken/build/src/index.js:137:20)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async JWT.refreshTokenNoCache (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/google-auth-library/build/src/auth/jwtclient.js:165:23)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async JWT.refreshAccessTokenAsync (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/google-auth-library/build/src/auth/oauth2client.js:209:19)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async JWT.getAccessTokenAsync (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/google-auth-library/build/src/auth/oauth2client.js:238:23)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async Object.module.exports.generateToken (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/service/notificationGetAccessTokenService.js:210:25)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async Object.module.exports.invokeGetAccessToken (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/service/notificationGetAccessTokenService.js:49:14)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: at async notificationGetAccessToken (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/controllers/notificationGetAccessTokenController.js:54:53) {
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: config: {
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.665 +05:30: method: 'POST',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: url: 'https://www.googleapis.com/oauth2/v4/token',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: data: {
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: grant_type: '< - See
errorRedactor
option ingaxios
for configuration>.',4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: assertion: '< - See
errorRedactor
option ingaxios
for configuration>.'4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: },
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: headers: {
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: 'Content-Type': 'application/x-www-form-urlencoded',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: 'User-Agent': 'google-api-nodejs-client/9.2.0',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: 'x-goog-api-client': 'gl-node/16.15.0',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: Accept: 'application/json'
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: },
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: responseType: 'json',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: paramsSerializer: [Function: paramsSerializer],
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: body: '< - See
errorRedactor
option ingaxios
for configuration>.',4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: validateStatus: [Function: validateStatus],
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: errorRedactor: [Function: defaultErrorRedactor]
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: },
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: response: undefined,
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: error: FetchError: request to https://www.googleapis.com/oauth2/v4/token failed, reason: connect ETIMEDOUT 142.250.192.170:443
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.666 +05:30: at ClientRequest. (/opt/MyTest/MyTest-ui/apis/MyTest-notification-get-accessToken/node_modules/node-fetch/lib/index.js:1501:11)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: at ClientRequest.emit (node:events:527:28)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: at TLSSocket.socketErrorListener (node:_http_client:454:9)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: at TLSSocket.emit (node:events:527:28)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: at emitErrorNT (node:internal/streams/destroy:157:8)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: at emitErrorCloseNT (node:internal/streams/destroy:122:3)
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: at processTicksAndRejections (node:internal/process/task_queues:83:21) {
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: type: 'system',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: errno: 'ETIMEDOUT',
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: code: 'ETIMEDOUT'
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: },
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: code: 'ETIMEDOUT'
4|MyTest UI Notification Get AccessToken | 20240313 16:46:06.667 +05:30: }
Node version on server :- v16.0.0
Node version on my local machine :- v16.20.0
library version :- ^9.6.3
Tried with library version : ^9.2 was facing same issue then migrated to 9.6.3
The text was updated successfully, but these errors were encountered: