-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OAuth token refreshing doesn't work #5
Comments
Update: I restarted and it did still work. However it didn't before. Is there an expiry on the refresh token of some sort? Thanks |
If you have updated the module to the latest one, then the token file got changed which meant that the easiest route fix that change was to reauth. I have had a refresh token used a week later without any issues. You can also read the Monzo documentation - https://monzo.com/docs - for information on the API itself, or ask in their Slack - https://developers.monzo.com/. |
Yeah, basically what @bartonp said. In theory as long as you set up the OAuth client correctly and the file is on the disk it should work automatically by refreshing the token when it expires (that is, on the first request after it expires). That said, I think I had a similar situation a couple of times and couldn't really pin point the reason. The whole OAuth part of current Monzo API is generally less than ideal and I'm mostly hoping that they'll fix it soon and do provide us with a stable 1.0 version of it. Feel free to leave comments here if you think the refreshing doesn't work 100% of the times, but please be as descriptive about the situation as you can so I can hopefully reproduce it and find the problem. |
And this is also true and could be the reason if you updated |
By the way, the only re-auth problem I have had is in
|
@bartonp hm, interesting, and definitely not how it's suppose to work. Could you please open another GitHub issue describing when was this happening? Thanks! |
This was before I updated so that wasn't causing the issue. |
Feel free to reopen this if the problem occurs again. |
Not sure how to re-open but I have had this issue again. Came to try out my script again and needed to re-auth - again it lasted about a day. I might try this on my pc and see if I have the same issue with the token dying. |
So could you go step by step through it? You successfully authenticated via. OAuth 2, But on the next day it didn't work - could you paste the error? Did it happen on |
Sure - it has actually just happened again.
Correct, I authorised by passing the arguments directly into the MonzoAPI() like this:
...and everything works fine. Survives shell and computer restart and works from any directory. Token still exists:
When I run again a day or so later without arguments I get the following error:
|
OK, thanks for the info, I appreciate it and will look into this. |
No problem - appreciate the help. I noticed from this:
That I had two token files. So I have deleted them both and re-authorised. Now I only have one:
I will let you know if/when it fails again or if this solved it. Though I'm not sure why it would have changed it's mind over which one to use. |
That's expected and should't be related - it's because of the token file format change from |
@delabere could you try one thing for me? Could you authenticate using OAuth, save somewhere the contents of Somewhat related - I should probably add some debug logging to the application : ) |
I get this error:
|
So it seems it happened again even faster this time. I need to re-authenticate and didn't realise. I will do that and then tell you what happens with the refresh. |
OK, then for some reason you can't refresh the token at all. First things first - could you check for me if you marked the created OAuth client as confidential in Monzo API playground? : -) |
@delabere you can check it by going to https://developers.monzo.com/apps/home and selecting your application: |
OK, so I'm currently out of ideas. Let me test a couple things out. |
The refresh token is looking for If you pass in the client_id and client_secret, and then add this code to the if client_secret is not None:
self._client_secret = client_secret
if client_id is not None:
self._client_id = client_id The documentation on refreshing the token can be seen here - https://monzo.com/docs/#refreshing-access - for reference. |
Thanks I've given that a go. I will report back in a day or so to see if my token holds up. Question: Do I need to set the remaining IF's to ELIF's in the init class? It didn't seem to cause any problems when running MonzoAPI() so I'm guessing now. |
@bartonp ah, you're right, I must've messed that up during recent refactoring - sorry about that. I'll try to have a bugfix release later today. |
@delabere The rest of the code stays the same in the init, only add what I mentioned above. You don't need to change anything else there. Let us know how it went, the non-refreshing part of the token I believe only lasts a couple of hours anyway :) |
@bartonp I also sent the refresh command mentioned earlier and it worked without error, and the token information changed. I think you've sorted it. |
Ooops - never came back. Can say that it's been working sine the @bartonp fix. Happy to test if there is a new release available . |
Closed via #8 |
Hi there,
Thanks again for the help with the previous issue.
Is there a way for me to restart my machine and then use MonzoAPI() without getting another Auth_Code for my Client?
Thanks,
Jack
The text was updated successfully, but these errors were encountered: