Switching to HTTP/2 makes calendarList.list() complain about invalid authentication
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, nodejs
- 领域
- api, authentication, networking
调研方向
首先使用 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 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googleapis/google-api-nodejs-client 的其他 Issue
-
难度 5/5 一周以上 新手友好度 32/100
googleapis/google-api-nodejs-client#3932 · 1 条评论 ·
维护者通常 1 天内回复
-
[Discovery Engine] streamAnswer is typed as one AnswerQueryResponse, but REST returns frame arrays未关闭
难度 3/5 1-2 天 新手友好度 64/100
googleapis/google-api-nodejs-client#3930 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 76/100
googleapis/google-api-nodejs-client#3927 · 1 个 reaction ·
维护者通常 1 天内回复
-
size: l type: feature request
难度 4/5 3-5 天 新手友好度 35/100
googleapis/google-api-nodejs-client#3926 ·
维护者通常 1 天内回复
-
type: feature request
难度 5/5 一周以上 新手友好度 15/100
googleapis/google-api-nodejs-client#3903 ·
维护者通常 1 天内回复
查看 googleapis/google-api-nodejs-client 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
callstackincubator/rozenite#518 ·
维护者通常 1 天内回复
-
Area/Workflow Priority/Blocker Type/Bug
难度 2/5 1-3 小时 新手友好度 76/100
wso2/product-integrator#2622 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
-
area:bash bug has repro platform:macos
难度 2/5 1-3 小时 新手友好度 78/100
anthropics/claude-code#98644 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
allure-framework/allure-js#1603 ·
维护者通常 1 天内回复