Creating an application and obtaining an access token programmatically

There are multiple ways to access YouTube data. We will focus on the most secure approach using OAuth authentication to access YouTube Data API resources. You can use the following steps:

  1. The first step is to create a project on the Google Developer console (https://console.developers.google.com/apis/)
  2. Then, you go to Credentials, click on Create Client ID, and choose Other.
  3. You will get a Client ID and a Client Secret that you will use for the next step.

 

  1. Firstly, we will use the oauth2client library to perform the first step in authorization:
from oauth2client.client import OAuth2WebServerFlow 
  1. Then, we use the credentials obtained in the previous step and we obtain the authorization URI:
client_id = 'YOUR_CLIENT_ID' 
client_secret = 'YOUR_CLIENT_SECRET' 
 
flow = OAuth2WebServerFlow(client_id=client_id, 
client_secret=client_secret, scope='https://gdata.youtube.com',
redirect_uri='YOUR_APP_URL') auth_uri = flow.step1_get_authorize_url()
  1. Then, you go to the following website in order to change the authorization token into an access token: https://developers.google.com/oauthplayground/.

You save the access token, which will be used to collect the data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.186.92