YouTube api 的永久访问令牌?

发布于 2024-11-14 11:57:27 字数 371 浏览 2 评论 0原文

我已经浏览了用于身份验证的 Oauth 和 AuthSub 方法的 google 文档,并且我尝试通过 google 搜索此内容,但没有结果。

对于 Facebook,您可以请求一个长度生命周期的访问令牌,这意味着您不必每隔几周请求一个新令牌。 Google,特别是 YouTube,有没有任何身份验证方法可以让您永久使用该令牌?

在他们的文档中,他们声明它们具有长寿命,但没有提供额外的详细信息,例如寿命到底有多长,以及您是否真的可以获得永不过期的产品。

具体来说,我正在制作一个需要每天登录几个帐户的应用程序,但它是通过 cron 运行的,因此不会有用户每次登录它,而且我不希望存储实际的用户/密码应用程序本身并使用令牌。

I have gone through the google documentations for Oauth and AuthSub methods for authenticating and I've tried to google this without results.

For Facebook, you can request an access token which is of length lifetime, meaning you won't have to be requesting a new token every few weeks. What about Google, and YouTube in specific, is there any authentication method which allows you to use that token permanently?

In their documentation they state that they have long-life but no sort of additional detail, of exactly how long and whether or not you could actually get one which never expires.

Specifically, I am making an application that needs to login on a few accounts daily, but it is run through cron so there isn't gonna be a user logging it in each time, and I'd prefer not store the actual user/pass to the application itself and use the tokens instead.

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

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

发布评论

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

评论(1

陌路终见情 2024-11-21 11:57:27

终于找到了。它们不会过期。您必须确保执行最后一步,将一次性令牌交换为会话令牌。该会话令牌不应过期。

这是我在 C# 中的步骤(使用 Google AuthSub 客户端库):

sessionToken = AuthSubUtil.exchangeForSessionToken(authToken, null);

足够简单。我确信 PHP 库可能非常相似。只需存储 sessionToken 而不是 authToken

查看 AuthSub 流程。具体来说是最后一步(#7)

Finally found it. They don't expire. You have to make sure to perform the last step, exchanging your single use token for a session token. That session token should not expire.

Here's what my step (using the Google AuthSub Client Library) looks like in C#:

sessionToken = AuthSubUtil.exchangeForSessionToken(authToken, null);

Simple enough. I'm sure it's probably something very similar for the PHP library. Just store that sessionToken instead of the authToken

Check out the AuthSub process flow. Specifically the very last step (#7)

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