YouTube API的永久访问令牌? [英] Permanent access token with YouTube api?

查看:152
本文介绍了YouTube API的永久访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经遍历了Google文档中的Oauth和AuthSub方法进行身份验证,并且我尝试在Google上搜索此方法而没有结果.

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

对于Facebook,您可以请求一个长度为 lifetime 的访问令牌,这意味着您不必每隔几周就请求一个新令牌.那么Google,特别是YouTube,有什么身份验证方法可以让您永久使用该令牌?

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?

在他们的文档中,他们声明他们具有长寿,但没有任何其他细节,确切地说是 long 的长短,以及您是否能真正获得一个到期.

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.

具体来说,我正在制作一个需要每天登录几个帐户的应用程序,但是它是通过cron运行的,因此不会有用户每次都登录它,所以我宁愿不存储实际的用户/传递给应用程序本身,并改为使用令牌.

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.

推荐答案

最后找到了它.他们不会过期.您必须确保执行最后一步,将一次性使用令牌替换为会话令牌.该会话令牌不应过期.

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.

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

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

sessionToken = AuthSubUtil.exchangeForSessionToken(authToken, null);

足够简单.我敢肯定,对于PHP库来说,这可能非常相似.只需存储该sessionToken而不是authToken

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

查看 AuthSub处理流程.特别是最后一步(#7)

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

这篇关于YouTube API的永久访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆