My app streams video from Google Drive. When it requests the URL, it retrieves an access token, but that expires after an hour causing the buffer to empty and the video to freeze.
I'm familiar with the hour limit on access tokens but unsure of how to use the refresh token to request a new access token while a video is still streaming since that would change the URL AVPlayer is using. Any tips?
Related
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/permission_delete?view=odsp-graph-online
Note: The #microsoft.graph.downloadUrl value is a short-lived URL and can't be cached. The URL will only be available for a short period of time (1 hour) before it is invalidated.
In the tutorial, the download url expires after an hour. How do I get a permanent download address?
error Message
Sorry, something went wrong
The access token has expired. It's valid from '11/11/2020 1:18:52 AM' and to '11/11/2020 2:18:52 AM'.
"The lifetime of an access token is 1 hour. Have you tried to use the refresh token to obtain a new access token, or customize the lifetime of the access token?"
Please try the same as suggested above by Carl. You need to use the refresh token to obtain a new access token or customize the lifetime of the access token. Here's the document.
Note: The #microsoft.graph.downloadUrl value is a short-lived URL and can't be cached. The URL will only be available for a short period of time (1 hour) before it is invalidated. Removing file permissions for a user may not immediately invalidate the URL.
The workaround was to create a share link for DriveItem and use the WebUrl as the result of the response.
The file was accessed and made available for download through WebUrl.
It seemed that the only way for non-tenant users to access it.
I want to download files in the background using NSUrlSessionDownloadTask.
To download I need to perform the following:
Perform a POST to get an auth token
Perform a GET to get a download URL using the auth token in the header. The URL I get back includes a temp token in a query parameter. E.g. https://myserver.com/file1?token=abc
Download from the URL I got in the previous step using NSUrlSessionDownloadTask
The token in the download URLs is valid for 3 hours after which I need to perform the process again and get a new URL with a new token.
I checked out NSUrlSessionDownloadTask and I have several problems:
I see there is support for for cert auth and basic auth challenges but not the the auth scheme I use. So, if the download takes more than 3 hours (e.g. because it was interrupted due to no network), I need to re-auth and get a new download URL. Is there a callback that I can use to do the re-auth stuff?
If I manage to re-auth, then I get a new URL. Can I switch URLs in the middle of the NSUrlSessionDownloadTask? In other words, can I continue a download with a different URL? (it is the same URL but the token in the query string is different).
YouTube API Specification (https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads) provides info about how checking the status and resume an incompleted upload.
But what about aborting a resumable upload? How long an incompleted upload can be resumed?
YouTube API does not provide this information directly.
It just says that
session URI has a finite lifetime and eventually expires
https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol
Google Drive talks about a week
A resumable session URI expires after one week.
https://developers.google.com/youtube/v3/guides/using_resumable_upload_protocol
https://developers.google.com/drive/api/v3/manage-uploads
Since the API is similar / same, it will be probably same
I'm attempting to use the resumable API to upload a video to YouTube with a refreshed access token. but I'm getting a 401 back when I've finished uploading the resumed part of the data. I get the following message back alongside the 401:
authError Invalid Credentials
But I can upload a new video with that refresh access token.
This is a bug on the server-side: https://stackoverflow.com/a/14320908/1970843, https://code.google.com/p/google-api-python-client/issues/detail?id=231, https://code.google.com/p/gdata-issues/issues/detail?id=5124
I had used my php AP for uploading youtube videos for 2 days,
All worked just fine.
But yesterday and today, I get this error when trying to upload videos to my youtube account.
yt:authentication Unknown
I am using OAuth2, all clientid , key, secret are correct
Any help ?
Whenever running into OAuth 2 weirdness, the first step I'd recommend is invalidating your existing grant from https://accounts.google.com/IssuedAuthSubTokens, and then going through the OAuth 2 approval flow again from scratch.
I have been using the PHP client library for the Google API and was having this same problem. In the v3 documentation, I couldn't find anything relating to a browser-based YouTube upload so I've ended up using the v3 API for some things (video and playlist retrieval, authentication etc.) but I'm still using the v2 method for browser-based uploading. All of this was working fine then suddenly stopped working. Jeff's suggestion of revoking the token does indeed work but the problem would just come back later.
What I had to do was check if the user's token had expired. Note that the YouTube token currently seems to expire after 60 minutes. If the token has expired, you need to make sure the user goes through the authentication process again. A quick example:
// $client is your previously authenticated instance of Google_Client
if ($client->isAccessTokenExpired())
{
// Redirect to your page which outputs $client->createAuthUrl() for them to authenticate again
}
It's probably worthwhile noting that $client->getAccessToken() still evaluates to true in conditionals even with an expired token.