an error 400:redirect_uri_mismatch occured when Connecting to google calendar
#1910
Unanswered
TrillStones
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
主要原因:Google Cloud Console 里登记的 Redirect URI,和 TaskNotes 实际请求的 Redirect URI 不一致。
你现在报错里写的是:
但你上传的教程里登记的是类似:
也就是 端口不同:8081 vs 42813,而且可能 路径也不同:有无
/callback。Google OAuth 要求必须逐字完全一致:协议、IP、端口、路径都要一致。教程第 19–21 页就是在配置Authorized redirect URIs。你应该这样改:
在 Google Cloud Console → APIs & Services → Credentials → 你的 OAuth Client ID → Authorized redirect URIs 里,新增:
如果 TaskNotes 后续实际跳转是带
/callback,再加:然后保存,等几分钟,再重新授权。
另外确认两点:
你这个错误不是账号问题,也不是 Calendar API 权限问题,核心就是 redirect_uri 没注册或注册错了。
ChatGPT 说:
flowName=GeneralOAuthFlow不是问题原因。它只是 Google 错误页里显示的内部参数,意思是:这次登录走的是 Google 的“通用 OAuth 授权流程”。真正导致失败的是前面的:
也就是 Google 收到的回调地址,和你在 Google Cloud Console 里登记的不完全一致。
最可疑的是这点:你可能把 URI 加到了 Authorized JavaScript origins,但真正需要加的是下面的 Authorized redirect URIs。
请只盯住这两个位置:
注意:如果报错里是
http://127.0.0.1:8080,就不要只填http://127.0.0.1:8080/callback。Google 要求完全一致,/callback多了也不行。如果还是不行,常见原因只剩这几个:
localhost和127.0.0.1不等价;http和https不等价;有无/callback不等价。redirect_uri=http://127.0.0.1:8080,所以先按这个精确注册。你现在重点检查:TaskNotes 设置里的 Client ID,是否就是 Google Cloud 里你刚刚添加
http://127.0.0.1:8080的那个 OAuth Client ID。你说:
是url里多了callback导致的。
展开收起
ChatGPT 说:
对,就是这个原因。
Google OAuth 的
redirect_uri必须逐字完全一致:和
是两个不同地址。
你这次报错请求的是:
所以 Google Cloud Console 里 Authorized redirect URIs 必须填不带
/callback的版本:可以保留
/callback,但不能替代不带/callback的那个。Beta Was this translation helpful? Give feedback.
All reactions