I am trying to access google youtube API using the auth2.0 method but am unable to get an access token.
Given Below python code
import os
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors
scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]
def main():
# Disable OAuthlib's HTTPS verification when running locally.
# *DO NOT* leave this option enabled in production.
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
api_service_name = "youtube"
api_version = "v3"
client_secrets_file = "client.json"
channel_id='channeld'
# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes)
credentials = flow.run_console()
youtube = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials)
Not Sure What I am missing here ? can you help out any suggestion are welcomed
Click on the link error details
. It will tell you the redirect uri your application is sending from.
Take that redirect uri and add it in google developer console, the redirect uri must exactly match.
Google OAuth2: How the fix redirect_uri_mismatch error. Part 2 server sided web applications.
The code you are using is designed for an installed application hence the oogle_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file
So to use it you need to create installed application credetials You appear to have done that. This code will open up the web browser consent screen on the machine its running on. This code is not designed for running on a web server.
Open your credentials.json file there should be two redirect URIs in there delete the urn:ietf:wg:oauth:2.0:oob one