Skip to content


If you want to get some more data for your channel. You need provide the authorization first.

So, this doc show how to do authorize.


At the beginning. You must know what is authorization.

You can see some information at the Official Documentation.

Then you need have an app with the Access scopes approval by YouTube.

If everything goes well. Now let do a simple authorize with Python-Youtube library.

Get authorization url

Suppose now we want to get user's permission to manage his youtube account.

For the Python-YouTube library, the default scopes are:


You can get more scope information at Access scopes.

And We set the default redirect url is https://localhost/.

Now we can begin do the follows step.

Initialize the api instance with you app credentials

In [1]: from pyyoutube import Client

In [2]: cli = Client(client_id="you client id", client_secret="you client secret")

In [3]: cli.get_authorize_url()

Now you get the authorization url, you just need copy the link, and open browser to paste the link, click the enter bar.

Do authorization

If you enter the url. you will see this.


Now you need to chose or enter you google account with youtube.

If your app have not got the approval from youtube. You will get an warning from youtube. If you have been approved, you will see the next image show directly.


For now, you need to click the button Advanced, then click the Go to Python-YouTube (unsafe).


Now you can get a window to give permissions.


click the blue button allow to give the permission.

Then you will get a Connection Error, don't worry. This just because we set the redirect link to localhost.

Retrieve access token

Now you need to copy the full url in the browser address bar. Then back to you console.

In [4]: token = cli.generate_access_token(authorization_response="the whole url")

In [5]: token
Out[5]: AccessToken(access_token='access token', expires_in=3600, token_type='Bearer')

now you have got your access token to visit your self data.

Get your data

For example, you can get your playlists.

In [6]: playlists = cli.playlists.list(mine=True)

In [7]: playlists.items
[Playlist(kind='youtube#playlist', id='PLBaidt0ilCManGDIKr8UVBFZwN_UvMKvS'),
 Playlist(kind='youtube#playlist', id='PLBaidt0ilCMbUdj0EppB710c_X5OuCP2g')]


If you have some confuse. you need to read the Authorize Requests first.