我正在尝试使用Python上传文件到Google Drive,并从Google Cloud上驱动API。但是,它的凭据在某个时候到期。该怎么办?

发布于 2025-02-12 11:25:01 字数 139 浏览 1 评论 0原文

我正在使用Python将文件上传到我的Google Drive,这只是一个简单的脚本。有时候它可以正常工作,但是有时我产生的凭据过期。在那里,我可以使这些凭证不终生过期。我还看了一些YouTube视频,他们建议使用刷新令牌。但是我不知道如何在脚本中生成和使用它们。

I am using python to upload files to my google drive, just a simple script. It works fine for sometimes but after sometimes the credentials which I generated expires. Is there as way I can make those credentials not to expire for life time. I also looked on to some YouTube videos who were suggesting something called refresh token. But I don't know how to generate and use them in my script.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2025-02-19 11:25:01

我要假设有时意味着7天。

这是因为如

与外部用户类型配置的OAuth同意屏幕和“测试”的发布状态的Google Cloud Platform项目在7天内发行了刷新令牌。

去Google可以安置您的项目。在OUATH2同意屏幕下,将您的项目设置为生产。您的刷新令牌将停止到期。

I am going to assume that sometime means seven days.

This is because as stated in oauth2#expiration

A Google Cloud Platform project with an OAuth consent screen configured for an external user type and a publishing status of "Testing" is issued a refresh token expiring in 7 days.

Go to google could console for your project. Under the Ouath2 consent screen and set your project to production. Your refresh tokens will stop expiring.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文