Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to login without local auth server #26

Merged
merged 1 commit into from
Oct 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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