Permanent access token with YouTube api?

℡╲_俬逩灬. 提交于 2019-12-09 10:57:11

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/6289417/permanent-access-token-with-youtube-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!