Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Use code to obtain token. During the process of auth2, the request https://oauth2.googleapis.com/token failed.

オープン
#3,450 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript, nodejs

調査の方向性

OAuth2Client.getToken の呼び出しと、https://oauth2.googleapis.com/token への報告された POST から始め、続いて ECONNRESET の詳細と、リンクされている Google OAuth のウェブサーバー例を確認します。クライアントライブラリとリクエスト環境のどちらがトークン交換の失敗を引き起こしているかを特定し、再現可能な解決策を文書化できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

priority: p2 size: m type: bug

I couldn't find the corresponding entry in [support console] and couldn't start, so I'm still here to ask for help.
I use [email protected] in my node project, the code is as follows:

const { google } = require('googleapis');

async getToken() {
const { ctx } = this;
const { code } = ctx.request.body;
const { client_id, client_secret, redirect_uri, } = ctx.app.config.oauth2Google;
const oauth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uri);
const data = await oauth2Client.getToken(code);
}

Wrong question:

config: {"method":"POST","url":"https://oauth2.googleapis.com/token","data":"< - See errorRedactor option in gaxios for configuration >.","headers":{"Content-Type":"application/x-www-form-urlencoded","User-Agent":"google-api-nodejs-client/9.6.3","x- goog-api-client":"gl-node/20.11.0"},"body":"< - See errorRedactor option in gaxios for configuration>.","responseType":"unknown" }
response: undefined
error: {"message":"request to https://oauth2.googleapis.com/token failed, reason: read ECONNRESET","type":"system","errno":"ECONNRESET","code":" ECONNRESET"}

Here is the official documentation: https://developers.google.com/identity/protocols/oauth2/web-server?hl=zh-cn#exchange-authorization-code

and code:
`const url = require('url');
// Receive the callback from Google's OAuth 2.0 server.
if (req.url.startsWith('/oauth2callback')) {
// Handle the OAuth 2.0 server response
let q = url.parse(req.url, true).query;

// Get access and refresh tokens (if access_type is offline)
let { tokens } = await oauth2Client.getToken(q.code);
oauth2Client.setCredentials(tokens);
}`

Thanks!

主要言語
TypeScript
スター
12.3k
フォーク
2k
平均マージ
2日 19時間
マージ済み PR(30日)
23

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleapis/google-api-nodejs-client のほかの issue

googleapis/google-api-nodejs-client の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。