YouTube API v3 - App Download Permission - Android

I am currently uploading a YouTube video using the YouTube v3 Android API based on the code here :

I want to do a download after a delay when the user can no longer be in the application. The problem I'm running into is that if the user hasn't already granted permissions for my YouTube upload app, it will boost the upload UserRecoverableAuthIOException

. In the documentation, then I should do the following:

startActivityForResult(uraioe.getIntent(), ACTION_REQUEST_AUTHORIZATION);

      

which displays a popup. For now, if the user has left the app, it is a bad experience for them to see the popup, if they see it at all. Can I pre-authorize my app to download permission before I download the file?

+3


source to share


1 answer


It looks like you want to use access and refresh tokens . While your user is using the app, they can authenticate their account and allow you to make requests on their behalf, resulting in an access token and a refresh token. Then, if they are sent offline, you just need to check if the access token has expired (usually an hour after creation), and if there is, use the refresh token and you can make authorized requests for them.

Note that tokens can expire if:



  • user revoked access.
  • the token has not been used for six months.
  • The user account has exceeded a certain number of token requests.
0


source







All Articles