mesozoic/gmail-yaml-filters

google auth not working, no helpful error

Closed this issue · 4 comments

I generated a client secret json file and I get this error when trying to use it:

❮ gmail-yaml-filters --dry-run --sync my-filters.yaml
Traceback (most recent call last):
  File "/home/mark/.local/bin/gmail-yaml-filters", line 33, in <module>
    sys.exit(load_entry_point('gmail-yaml-filters==0.9.5', 'console_scripts', 'gmail-yaml-filters')())
  File "/home/mark/.local/lib/python3.10/site-packages/gmail_yaml_filters/main.py", line 99, in main
    credentials = get_gmail_credentials(client_secret_path=args.client_secret)
  File "/home/mark/.local/lib/python3.10/site-packages/gmail_yaml_filters/upload.py", line 273, in get_gmail_credentials
    credentials = store.get()
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/client.py", line 407, in get
    return self.locked_get()
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/file.py", line 54, in locked_get
    credentials = client.Credentials.new_from_json(content)
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/client.py", line 302, in new_from_json
    module_name = data['_module']
KeyError: '_module'

That's not an error I've ever seen before. It looks like malformed credentials, though; you might try backing up and deleting ~/.credentials/gmail_yaml_filters.json and running again.

ok, more problems :)

  1. I forgot about that file because it is not in the docs and I had put it there after getting an error the first time
  2. The --client-secret option doesn't work, it still wants ~/.credentials/gmail_yaml_filters.json
❯ gmail-yaml-filters --dry-run --sync my-filters.yaml --client-secret ./client_secret.json 
/home/mark/.local/lib/python3.10/site-packages/oauth2client/_helpers.py:255: UserWarning: Cannot access /home/mark/.credentials/gmail_yaml_filters.json: No such file or directory
  warnings.warn(_MISSING_FILE_MESSAGE.format(filename))
Traceback (most recent call last):
  File "/home/mark/.local/bin/gmail-yaml-filters", line 33, in <module>
    sys.exit(load_entry_point('gmail-yaml-filters==0.9.5', 'console_scripts', 'gmail-yaml-filters')())
  File "/home/mark/.local/lib/python3.10/site-packages/gmail_yaml_filters/main.py", line 99, in main
    credentials = get_gmail_credentials(client_secret_path=args.client_secret)
  File "/home/mark/.local/lib/python3.10/site-packages/gmail_yaml_filters/upload.py", line 275, in get_gmail_credentials
    flow = oauth2client.client.flow_from_clientsecrets(client_secret_path, scopes)
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/_helpers.py", line 133, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/client.py", line 2134, in flow_from_clientsecrets
    client_type, client_info = clientsecrets.loadfile(filename,
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/clientsecrets.py", line 165, in loadfile
    return _loadfile(filename)
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/clientsecrets.py", line 126, in _loadfile
    return _validate_clientsecrets(obj)
  File "/home/mark/.local/lib/python3.10/site-packages/oauth2client/clientsecrets.py", line 99, in _validate_clientsecrets
    raise InvalidClientSecretsError(
oauth2client.clientsecrets.InvalidClientSecretsError: Missing property "redirect_uris" in a client type of "web".
  1. When I copy the secrats.json to ~/.credentials/gmail_yaml_filters.json I get the same error as I originally stated.

when creating google credentials, what do I put for authorized javascript origins and authorized redirect URLs?

ok, I enabled gmail api in my GCP project or whatever it is called, and then I created a set of desktop credentials instead of Web like the link in the README points to. Then when I ran gmail-yaml-filters it popped up a web page to auth me to google and then wrote the ~/.credentials/gmail_yaml_filters.json. It would have been incredibly helpful to have that workflow for setting up credentials in the documentation.