mbrt/gmailctl

Feature Request: Renew Token

peteroneilljr opened this issue · 3 comments

It would be nice if gmailctl had a command or sub-command to reset the API token.

Once the gmail API token has expired gmailctl shows this error.

Error: getting filters from Gmail: Get "https://gmail.googleapis.com/gmail/v1/users/me/labels?alt=json&prettyPrint=false": oauth2: cannot fetch token: 400 Bad Request
Response: {
  "error": "invalid_grant",
  "error_description": "Token has been expired or revoked."
}

The current process is it delete ~/.gmailctl/token.json then run the init process again.

Proposed solution: gmailctl init --renew-token this would delete the current token and start the init process again.

Thanks!
Peter

mbrt commented

This is probably because you generated your credentials incorrectly. See the gmailctl init instructions here. Set your "publishing status" to "in production" and get rid of the testing accounts.

Please reopen if you still see problems after changing that.

@mbrt Where exactly can this "Publishing status" be set? I'm not seeing it anywhere, and in general the Google cloud console UI doesn't seem to match the instruction very closely. The instruction probably needs to be clarified and/or revised.

mbrt commented

@intelfx I don't see any difference in the Google Cloud console since when I last updated the instructions, so it seems they should still be OK?

I still see a "Publishing status" section in "API & Services > OAuth consent screen". It will appear after you "configure and register your app", the first time you navigate to the "OAuth consent screen".

Please follow https://github.com/mbrt/gmailctl/blob/master/cmd/gmailctl/cmd/init_cmd.go#L23 step-by-step.