Browse Source

Check if scopes are corrects in youtube credentials

develop
LecygneNoir 5 years ago
parent
commit
75aa36e1aa
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      lib/yt_upload.py

+ 11
- 0
lib/yt_upload.py 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

Loading…
Cancel
Save