Skip to content

Commit

Permalink
Merge 89bf8f7 into 0509249
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnekaunisto committed Oct 10, 2020
2 parents 0509249 + 89bf8f7 commit 9da21e7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions simple_youtube_api/Channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def login(
client_secret_path: str,
storage_path: str,
scope=youtube_api.SCOPES,
auth_local_webserver=True,
):
"""Logs into the channel with credentials
Expand All @@ -75,14 +76,26 @@ def login(
the path where the login is saved into
scope
Sets the scope that the login will ask for
auth_local_webserver
Wheter login process should use local auth webserver, set this to
false if you are not doing this locally.
"""

STORAGE = Storage(storage_path)
credentials = STORAGE.get()

if credentials is None or credentials.invalid:
saved_argv = []
if auth_local_webserver is False:
saved_argv = sys.argv
sys.argv = [sys.argv[0], "--noauth_local_webserver"]

flow = flow_from_clientsecrets(client_secret_path, scope=scope)
http = httplib2.Http()
credentials = run_flow(flow, STORAGE, http=http)

sys.argv = saved_argv

self.channel = build(
API_SERVICE_NAME, API_VERSION, credentials=credentials
)
Expand Down

0 comments on commit 9da21e7

Please sign in to comment.