令牌已过期或被撤销 - Google Ads令牌、已过期、Ads、Google

2023-09-07 10:24:38 作者:溺水旳情书

您好,我一直在使用 rest 方法将 Google Ads API 集成到 C# 中.一切似乎都运行良好,但突然间我开始收到 400 响应错误消息.

Hi I have been using rest methods to integrate Google Ads API in C#. Everything seemed to be working fine but all of sudden I started getting 400 response with the error message.

{
    "error": "invalid_grant",
    "error_description": "Token has been expired or revoked."
}

如上所述,我没有使用客户端库,而是使用 restsharp 并使用邮递员测试我的所有端点.

As mentioned above that I am not using client library but instead using restsharp and testing all my end points using postman also.

发生这种情况的任何原因?我的刷新令牌也是有效的.我已经使用了一个星期.我也没有达到刷新令牌的限制,因为我在尝试设置帐户时只生成了 3 到 4 次刷新令牌.

Any reason why it is happening? My refresh token is also valid. I have been using this for one week. I have also not reached to the limit of refresh token as I have only generated refresh token 3 to 4 times when I was trying to set up the accounts.

我相信刷新令牌的有效期是终身的,那为什么会发生呢?

I believe the validity of refresh token is life long then why it is happening?

推荐答案

我通过使用 Playground 生成新的刷新令牌解决了这个问题.过期的原因是我项目的 OAuth 同意屏幕的发布状态是测试模式.

I solved the problem by generating new refresh token using playground. The reason it expired because the publishing status of OAuth consent screen of my project was on testing mode.

如果您正在集成 API,则需要为 生产 应用发布状态,以避免在过期时手动生成刷新令牌.

If you are integrating an API, you need to apply publishing status for production to avoid manual generation of refresh tokens when it expires.