z411 / trackma

Open multi-site list manager for Unix-like systems. (ex-wMAL)
https://z411.github.io/trackma
GNU General Public License v3.0
779 stars 81 forks source link

Anilist PIN/Token Trouble #93

Closed MadeOfMagicAndWires closed 9 years ago

MadeOfMagicAndWires commented 9 years ago

Trackma is suddenly having trouble with connecting to Anilist, saying the PIN has become invalid, despite Trackma showing up under 'Approved Apps' on the site. Tried refreshing the PIN. Deleting and re-adding the account on trackma, even tried making a fresh account, nothing worked.
Also tried reversing https://github.com/z411/trackma/commit/c945a2f9688b97386bf8292a581f217aa87bb31a which also did not solve the problem; not that I thought it would.

The Docs don't seem to indicate it, but maybe something in the API has changed?

z411 commented 9 years ago

Just tried it with a fresh install of Trackma and I can't reproduce the problem. Could you please post the output you get?

I did notice that I get an error when trying to get a PIN if I'm not already logged into the site beforehand, though.

MadeOfMagicAndWires commented 9 years ago

Never mind, I just moved my old home folder, rather than just deleting the single account, and that seems to have fixed it. I'll take a look my configuration files, as far as I'm concerned this can be closed, and if this issue returns again, or I find out what was wrong, I'll let you know.

As for output, here's some simple one, just logging in and retrieving the list.

Initializing engine...
Engine: Trackma v0.3 - using account ToostInc(anilist).
Engine: Reading config files...
Data: Initializing...
libanilist: Initializing...
Data: Using libanilist (anime)
libanilist: Refreshing access token...
Data warning: Couldn't download list! Using cache.
Tracker: Initializing...
Tracker: Using inotify.

Ready. Type 'help' for a list of commands.
Press tab for autocompletion and up/down for command history.

ToostInc@Anilist(anime) Watching> retrieve
libanilist: Refreshing access token...
<class 'trackma.utils.APIError'>: Invalid PIN. It is either probably expired or meant for another application.
z411 commented 9 years ago

Thank you for the report. This shouldn't happen at all so I'll keep this open for a while until we can fix it properly. (P.D.: The tokens are stored in ~/.trackma/(name).anilist/user.json)

MadeOfMagicAndWires commented 9 years ago

Well, I couldn't find anything glaringly obvious that was wrong with my old configuration files, but I figure that , if anything, it probably was some leftovers from when I used the anilist branch before it was merged into master.

MadeOfMagicAndWires commented 9 years ago

Just a small update to say this happened once more, again fixed by refreshing the configurations, still don't know what's causing this.

I think this time it was triggered by changing from anime to manga mode, previously by using the search function, so maybe there's something going on with refreshing tokens for different types of requests?

z411 commented 9 years ago

Thank you a lot for reporting this; maybe the token isn't getting refreshed after it's past its expiration time, but I've seen it getting refreshed several times. The user configuration where the token is stored is used by the entire API, so there shouldn't be problems with different requests. I'll test it out either way though.

The Invalid PIN error is thrown when the server replies with a 400 error; I should change this to show the specific error details returned by the server.

z411 commented 9 years ago

I was able to reproduce this. The error I'm getting from the server is:

"The refresh token is invalid."

I'm guessing the refresh token also has an expiration date, but I can't see anything about it in the docs. I'll ask Josh.

joshstar commented 9 years ago

The refresh token doesn't have have expiration date, though at one point they did by accident. Re-authorizing the client should fix that anyway.

wizbright commented 9 years ago

I've been having issues with reauthoring the client and the tokens. I keep sending changes and it stalls on them for some reason.

z411 commented 9 years ago

Hi wizbright: Do you see any information in the console when it stalls?

wizbright commented 9 years ago

I did not but I decided to clear out my .trackma and did a reinstall and somehow it is working again. Sorry about that.