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

Switching to HTTP/2 makes calendarList.list() complain about invalid authentication

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

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

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

評価

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

調査の方向性

まず google.options({ http2: true }) と calendarApi.calendarList.list() を使用してスタンドアロンの OAuth2 再現を実行し、次に Node.js クライアントが Authorization の処理に使用する HTTP/2 リクエストパスを調査します。HTTP/2 を使用しないパスと比較します。HTTP/2 が有効な場合でも、認証済みの calendar-list リクエストが 401 を返さなくなれば完了です。

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

説明

I have an application that uses an access token to request a list of calendars and then deletes and creates batches of events in a specific calendar.

Everything works, but when I switch on HTTP/2 support:

google.options({
  http2: true
})

I get this exception when making the await calendarApi.calendarList.list() call:

Request failed with status code 401.                                     
'{                                                                                                              
  error: {                                                                                                      
    code: 401,                                                                                                  
    message: 'Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.',
    errors: [                                                                                                   
      {                                                 
        message: 'Invalid Credentials',                                                                         
        domain: 'global',                                                                                       
        reason: 'authError',                                                                                    
        location: 'Authorization',                                                                              
        locationType: 'header'                                                                                  
      }                                                                                                         
    ],                                                                                                          
    status: 'UNAUTHENTICATED'                           
  }                                                                                                             
}

Here's my code (using dotenv and extracted from my project as a standalone test case):

#!/usr/bin/env node

import 'dotenv/config'
import { google } from 'googleapis'

// When this is turned on, requesting the calendar list fails
google.options({ http2: true })

const authClient = new google.auth.OAuth2(
  process.env.GOOGLE_CLIENT_ID,
  process.env.GOOGLE_CLIENT_SECRET,
  'http://localhost:2024',
)

authClient.setCredentials({
  access_token: process.env.GOOGLE_ACCESS_TOKEN,
  refresh_token: process.env.GOOGLE_REFRESH_TOKEN,
})

const calendarApi = google.calendar({
  version: 'v3',
  auth: authClient,
})

let response

try {
  console.log('Requesting list of calendars...')
  response = await calendarApi.calendarList.list()
} catch(e) {
  console.error(e.message)
  process.exit(1)
}

console.log(response.data.items)

I'm using googleapis 144.0.0 and I tried multiple older versions and the result is the same.

My motivation for switching to HTTP/2 was hitting the "rate limit exceeded" error while performing too many simultaneous operations.

@jrmdayn's drop-in batch request add-on seems to work perfectly for batching the operations and not hitting the rate limit albeit without using HTTP/2, as per https://github.com/googleapis/google-api-nodejs-client/issues/2375#issuecomment-1377330182.

However, I'm still interested in switching to HTTP/2 for its performance benefits and due to it being the new standard.

@JustinBeckwith, I see that you've done a lot of work on the HTTP/2 implementation (#1130). I don't know if you can tell right away what is going on here.

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

環境構築

はじめの一歩

  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 を短くまとめたダイジェスト。