Check if scopes are corrects in youtube credentials

This commit is contained in:
LecygneNoir 2018-10-18 22:52:06 +02:00
parent 070408bb67
commit 75aa36e1aa

View file

@ -9,6 +9,7 @@ import time
import copy import copy
import json import json
from os.path import splitext, basename, exists from os.path import splitext, basename, exists
import os
import google.oauth2.credentials import google.oauth2.credentials
import datetime import datetime
import pytz import pytz
@ -80,6 +81,16 @@ def get_authenticated_service():
return build(API_SERVICE_NAME, API_VERSION, credentials=credentials, cache_discovery=False) return build(API_SERVICE_NAME, API_VERSION, credentials=credentials, cache_discovery=False)
def check_authenticated_scopes():
if exists(CREDENTIALS_PATH):
with open(CREDENTIALS_PATH, 'r') as f:
credential_params = json.load(f)
# Check if all scopes are present
if credential_params["_scopes"] != SCOPES:
logging.warning("Youtube: Credentials are obsolete, need to re-authenticate.")
os.remove(CREDENTIALS_PATH)
def initialize_upload(youtube, options): def initialize_upload(youtube, options):
path = options.get('--file') path = options.get('--file')
tags = None tags = None