I got some code from youtube data API's try-it editor.
I have some curl code here, I have the API Key, but I don't know what [YOUR ACCESS TOKEN]
is. I've been trying for the past two hours to find something, but couldn't get what I wanted.
I had an Oauth 2.0 client ID [742151xxxxxx.app.googleuserconsent.com]
in google developers console.
I used it in place of [YOUR ACCESS TOKEN]
but still got the authorization error.
Here is the cURL code:
curl \
'https://www.googleapis.com/youtube/v3/playlistItems?part=id%2C%20snippet&playlistId=pbsF2UOcspaGQkAe1BCAR395sue-tp5r&key=[YOUR_API_KEY]' \
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
--header 'Accept: application/json' \
--compressed
Here is the error JSON:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
The access token lets the application authorize requests on the user's behalf, and the refresh token lets the application retrieve a new access token when the original access token expires.
Clicking the question mark next to credentials in the try it editor provides some more information about the different authentication types offered,
The google OAuth 2.0 Client Libraries offer a further explanation about the access tokens and how to obtain them including some pre-made libraries in a few languages.
https://developers.google.com/identity/protocols/oauth2#libraries
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With