I'm trying to create a playlist:
#Imports
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import json
#Load secrets
with open('client_secret_XXXX.apps.googleusercontent.com.json', 'r') as f:
info = json.load(f)
#Credentials
creds = Credentials.from_authorized_user_info(info=info, scopes=["https://www.googleapis.com/auth/youtube"])
#API
youtube = build('youtube', 'v3', credentials=creds)
#Create playlist
youtube.playlists().insert(
part='snippet',
body={
'snippet': {
'title': 'MyNewPlaylistTest',
'privacyStatus': 'private'
}
}
).execute()
The error that appears:
Traceback (most recent call last): File "x.py", line 9, in <module>
creds = Credentials.from_authorized_user_info(info=info, scopes=["https://www.googleapis.com/auth/youtube"])
File "y.py", line 352, in from_authorized_user_info
**raise ValueError( ValueError: Authorized user info was not in the expected format, missing fields client_secret, client_id, refresh_token**.
I'm using the json credentials from the Client ID in OAuth2.0 in my google cloud.
--
Content of the client secret json:
{"installed":{
"client_id":"XXXX.apps.googleusercontent.com",
"project_id":"YYYYYYYY-XXXX",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"XXXXX/oauth2/v1/certs",
"client_secret":"XXXXXXXX",
"redirect_uris":["http://XXXXX"]
}
}