gpt4 book ai didi

node.js - NodeJS Invalid_grant gaxios.js :85:23

转载 作者:行者123 更新时间:2023-12-01 23:54:48 24 4
gpt4 key购买 nike

在我的 Node.js 应用程序中,我使用带有 oauth2 身份验证的 googleapis 来发送电子邮件。突然,我在启动应用程序时发现了这个错误。

(node:1333) UnhandledPromiseRejectionWarning: Error: invalid_grant
at Gaxios._request (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/gaxios/build/src/gaxios.js:85:23)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async OAuth2Client.refreshTokenNoCache (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/google-auth-library/build/src/auth/oauth2client.js:170:21)
at async OAuth2Client.refreshAccessTokenAsync (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/google-auth-library/build/src/auth/oauth2client.js:194:19)
at async OAuth2Client.getAccessTokenAsync (/Users/danielefarina/Desktop/GIT/server-worldmarker/src/node_modules/google-auth-library/build/src/auth/oauth2client.js:214:23)
(node:1333) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1333) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

你知道如何解决它吗?

最佳答案

我遇到了完全相同的问题,我能够通过在 oauthplayground 中重新生成 refresh_token 来解决这个问题.具体来说,我从这个 guide 做了第 4 步为了获得一个新的刷新 token ,我在我的应用程序中替换了它,并使用现有的 client_id 和 secret_id 一切都按预期继续工作。

我不是 oauth 专家所以我不能完全解释为什么会这样,但在做了一些研究后我发现刷新 token 确实过期了(我认为他们没有),并且出于某种原因我可能一个月前的刷新 token 突然停止工作。

这是一篇很好的文章,对刷新 token 做了一些解释:https://medium.com/@bantic/more-oauth-2-0-surprises-the-refresh-token-1831d71f4af6 .

在这里你可以找到关于刷新 token 过期的官方解释:https://developers.google.com/identity/protocols/oauth2#expiration

我希望这能帮助您解决问题。

干杯

关于node.js - NodeJS Invalid_grant gaxios.js :85:23,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62953009/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com