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

auth_google.py changes to remove local webserver requirement #29

Closed
bgtron opened this issue May 17, 2017 · 2 comments
Closed

auth_google.py changes to remove local webserver requirement #29

bgtron opened this issue May 17, 2017 · 2 comments

Comments

@bgtron
Copy link

bgtron commented May 17, 2017

A suggestion for improvement:
In setting up the Google authentication on a GUI-less machine, the auth_google.py script throws an option for "--noauth_local_webserver", but the way auth_google.py is coded, it doesn't actually work. So, here's a suggestion for improvement that uses the oauth2 parser and adds a few arguments.

!/usr/bin/env python
import sys, argparse

from oauth2client.file import Storage
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run_flow, argparser

def main():
  parser = argparse.ArgumentParser(parents=[argparser])
  parser.add_argument('client_id')
  parser.add_argument('client_secret')

  # Scopes of authorization
  activity = "https://www.googleapis.com/auth/fitness.activity.write"
  body = "https://www.googleapis.com/auth/fitness.body.write"
  location = "https://www.googleapis.com/auth/fitness.location.write"
  scopes = activity + " " + body + " " + location

  flags = parser.parse_args()
  flow = OAuth2WebServerFlow(flags.client_id, flags.client_secret, scopes)
  storage = Storage('google.json')
  run_flow(flow, storage, flags)

if __name__ == '__main__':
  main()

This slight modification in the code now properly parses the "--noauth_local_webserver" out of the args no matter the order when entered in the command line.

@pkpio
Copy link
Owner

pkpio commented May 19, 2017

@bgtron, Thanks for the clear suggestions. Headless setup is definitely one of the top requests. Hopefully next week I will have some time to fix this and a bunch of others. Would you be willing to make some contribution for the Google Authenticator headless setup? - I guess just send the above suggestion as a PR?

Would love to have more users involved as contributors.

@pkpio
Copy link
Owner

pkpio commented Jun 1, 2017

@bgtron Resolved along with #16

@pkpio pkpio closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants