mattn / go-mastodon

mastodon client for golang
MIT License
600 stars 85 forks source link

"bad authorization: 401 Unauthorized: invalid_grant" #106

Closed KopfKrieg closed 5 years ago

KopfKrieg commented 5 years ago

I'm currently trying to write a mastodon bot (source code is available here), but unfortunately I get a "invalid_grant" error. The exact error message is:

bad authorization: 401 Unauthorized: invalid_grant

If I register my app and the immediately post a status everything's fine. But the bots purpose is to post every 3.56 days the current status of the year (e.g. "51% if the year is over"), and this somehow leads to the mentioned error. Any idea on how to debug this? Or what I could do about it?! Currently I'm using username/password for authentication, so this shouldn't be a problem (IMHO, not sure about that). Is there maybe a (hidden) access token that gets invalid after a certain time?

Edit: The instance I'm using is mastodon.bayern (Mastodon v2.8.0), and the account is marked as "bot". Not sure if this makes any difference.

mattn commented 5 years ago

Probably, this is related issue.

https://github.com/tootsuite/mastodon/issues/1681

KopfKrieg commented 5 years ago

I'm sorry, the problem is fixed now. I registered the bot, but did not save the access token (unfortunately there's no documentation on this, but someone helped me out). Without the access token, I get the 401 error. If I save it everything's fine. Issue can be closed.