Permanent access token with YouTube api?
Asked Answered
V

1

7

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.

Vandervelde answered 9/6, 2011 at 7:23 Comment(3)
I haven't seen any definitive documentation from Google on that either. I'm doing something pretty similar to what you are and my tokens haven't expired yet (probably been around a week), but that doesn't mean they aren't going to at some point.Liegeman
I would really need something that would last at least 2-4 months minimum for it to be worth using instead of just storing the user/pass.Vandervelde
Same here.. I am looking forward to seeing what the answer is!Liegeman
L
4

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)

Liegeman answered 9/6, 2011 at 20:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.