Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3831

Authorization Error when Connecting to Youtube Analytics API with Python

$
0
0

I have been trying to connect during several days to the YouTube Analytics API. I see that the solution in other posts is related about selecting 'Others' in the Application Type list. Apparently, this option is not available anymore.

I have created two different OAuth 2.0 clients: Web Application and Desktop. For the first one, it is displaying the following error:

  • Error 400: redirect_uri_mismatch: The redirect URI in the request, urn:ietf:wg:oauth:2.0:oob, can only be used by a Client ID for native application. It is not allowed for the WEB client type.

Then, it is when I try to create a native application (Desktop App in this case), it is sending a new error message:

  • Error 400: invalid_request. You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure. You can let the app developer know that this app doesn't comply with one or more Google validation rules.

I have read the Google's OAuth 2.0 policy but I am not able to understand why it doesn't comply. It's not quite specific.

Anyone that has had the same issue? This is the sample code that I have been using:

import googleapiclient.errorsimport osfrom googleapiclient.discovery import buildfrom google_auth_oauthlib.flow import InstalledAppFlowfrom google.auth.transport.requests import Requestscopes = ["https://www.googleapis.com/auth/youtube.readonly"]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 = "youtubeAnalytics"    api_version = "v2"    client_secrets_file = "cliente_analytics.json"    # 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_analytics = googleapiclient.discovery.build(        api_service_name, api_version, credentials=credentials)    request = youtube_analytics.reports().query(        dimensions="day",        endDate="2021-04-01",        ids="channel==MINE",        maxResults=5,        metrics="likes",        startDate="2021-03-01"    )    response = request.execute()    print(response)if __name__ == "__main__":    main()

Thanks


Viewing all articles
Browse latest Browse all 3831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>