Reputation: 7421
It seems that v2 was created quite a long time ago so I'm focusing on getting my needs met with v3. The Python code examples for v3 are all very long and although I have created a project in my Google account and an API key, downloaded client_secrets.json
:
{
"installed": {
"client_id": "********",
"project_id": "my-project",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "***********",
"redirect_uris": [
"urn:ietf:wg:oauth:2.0:oob",
"http://localhost"
]
}
}
have so far not made much progress with the code samples.
So am testing something simpler, just to get the Python Requests library to pull this request -
GET https://www.googleapis.com/youtube/v3/videoCategories
found in the official v3 documentation here.
Am using the following code with elements from the json above:
import requests
r = requests.get("https://www.googleapis.com/youtube/v3/videoCategories", auth=(client_id, client_secret))
r.status_code
This is returning 403 (Forbidden) so can't move forward at this stage. Does anyone know how to get this to work and if it is even possible?
Upvotes: 1
Views: 2059
Reputation: 117146
403 (Forbidden)
means that you don't have access to do what you are trying to do. You should check the full error message you are getting from the server there is normally more then just that.
videoCategories.list is a public method get an API key from the Google Developer Console and just tack it on the end
https://www.googleapis.com/youtube/v3/videoCategories?key=yourkey
Using the official Google python client library will make your life a lot easer. Once you start working with methods that require Oauth2 you don't want to have to code that yourself if you can avoid it.
Upvotes: 1