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

Google API OAuth 2 Error, MUST INCLUDE HTTPS

$
0
0

first time trying myself on scripting.I created a script to access the youtube API and later upload a video; here is the beginning of the script:

import osimport timeimport jsonfrom google.oauth2.credentials import Credentialsfrom google_auth_oauthlib.flow import Flowfrom googleapiclient.discovery import buildfrom googleapiclient.errors import HttpError# Set the folder to monitorfolder_path = 'D:/test/'# Set the interval for checking the folder (in seconds)check_interval = 60# Set the YouTube API credentialsclient_secrets_file = 'client_secrets.json'scopes = ['https://www.googleapis.com/auth/youtube.upload']api_service_name = 'youtube'api_version = 'v3'# Load the list of uploaded videos from a fileuploaded_videos_file = 'uploaded_videos.json'if os.path.exists(uploaded_videos_file):    with open(uploaded_videos_file, 'r') as f:        uploaded_videos = json.load(f)else:    uploaded_videos = []def get_authenticated_service():"""Gets an authenticated YouTube API service."""    flow = Flow.from_client_secrets_file(client_secrets_file, scopes)    flow.redirect_uri = 'https://localhost:8080'    authorization_url, state = flow.authorization_url(        access_type='offline',        include_granted_scopes='true')    print('Please go to this URL: {}'.format(authorization_url))    authorization_response = input('Enter the authorization code: ')    flow.fetch_token(authorization_response=authorization_response)    credentials = flow.credentials    return build(api_service_name, api_version, credentials=credentials)

Now when entering my authorization code i get the following error:

Traceback (most recent call last):  File "uploadtoyoutube2.py", line 90, in <module>    upload_video(video_file)  File "uploadtoyoutube2.py", line 57, in upload_video    youtube = get_authenticated_service()              ^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "uploadtoyoutube2.py", line 40, in get_authenticated_service    flow.fetch_token(authorization_response=authorization_response)  File "\Python\Python311\Lib\site-packages\google_auth_oauthlib\flow.py", line 285, in fetch_token    return self.oauth2session.fetch_token(self.client_config["token_uri"], **kwargs)           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "Python\Python311\Lib\site-packages\requests_oauthlib\oauth2_session.py", line 244, in fetch_token    self._client.parse_request_uri_response(  File "Python\Python311\Lib\site-packages\oauthlib\oauth2\rfc6749\clients\web_application.py", line 220, in parse_request_uri_response    response = parse_authorization_code_response(uri, state=state)               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File "Python\Python311\Lib\site-packages\oauthlib\oauth2\rfc6749\parameters.py", line 272, in parse_authorization_code_response    raise InsecureTransportError()oauthlib.oauth2.rfc6749.errors.InsecureTransportError: (insecure_transport) OAuth 2 MUST utilize https.

I don't know where I am not using https. the redirect uri uses https, all urls appearing in the client_secrets file are using https as well. This is my first project so sorry for my lack of knowledge and me possibly missing crucial details and I hope someone can help! Thanks for your time.


Viewing all articles
Browse latest Browse all 3831

Trending Articles



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