jamesread / prometheus-gmail-exporter

Checks gmail labels for unread messages and exposes the counts via prometheus.
Apache License 2.0
47 stars 9 forks source link

ValueError: Authorized user info was not in the expected format, missing fields refresh_token. #24

Closed vorburger closed 1 year ago

vorburger commented 1 year ago

@jamesread do you have any idea what could have caused this:

$ ./gmail-exporter.py 
INFO:root:prometheus-gmail-exporter is starting up.
INFO:root:UID: [REDACTED]
INFO:root:Home directory: /home/vorburger
Traceback (most recent call last):
  File "/home/vorburger/git/github.com/jamesread/prometheus-gmail-exporter/./gmail-exporter.py", line 273, in <module>
    main()
  File "/home/vorburger/git/github.com/jamesread/prometheus-gmail-exporter/./gmail-exporter.py", line 235, in main
    GMAIL_CLIENT = get_gmail_client()
  File "/home/vorburger/git/github.com/jamesread/prometheus-gmail-exporter/./gmail-exporter.py", line 226, in get_gmail_client
    return discovery.build('gmail', 'v1', credentials = get_credentials())
  File "/home/vorburger/git/github.com/jamesread/prometheus-gmail-exporter/./gmail-exporter.py", line 48, in get_credentials
    credentials = Credentials.from_authorized_user_file(args.credentialsPath, SCOPES)
  File "/home/vorburger/git/github.com/jamesread/prometheus-gmail-exporter/.venv/lib/python3.10/site-packages/google/oauth2/credentials.py", line 440, in from_authorized_user_file
    return cls.from_authorized_user_info(data, scopes)
  File "/home/vorburger/git/github.com/jamesread/prometheus-gmail-exporter/.venv/lib/python3.10/site-packages/google/oauth2/credentials.py", line 390, in from_authorized_user_info
    raise ValueError(
ValueError: Authorized user info was not in the expected format, missing fields refresh_token.
vorburger commented 1 year ago

@jamesread I am not seeing this anymore. I think, but I'm not really sure, that #27 helped; so closing this. (Unless you want to re-open this for further investigation.)

PS: I had also figured that one can, of course, "work around" (cough) this with rm ~/.prometheus-gmail-exporter/* and starting over.

jamesread commented 1 year ago

Yeah, I figure you maybe had a broken client_secret or login_cookie. Close for now if you cannot reproduce, but also glad it's working :-)