Skip to content
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

Monzo API HTTP 401 response didn't trigger token refreshing #6

Closed
bartonp opened this issue Sep 23, 2017 · 3 comments
Closed

Monzo API HTTP 401 response didn't trigger token refreshing #6

bartonp opened this issue Sep 23, 2017 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bartonp
Copy link
Contributor

bartonp commented Sep 23, 2017

There was a use case where the reauth wasn't doing the required actions. I added my own checks in to see what was happening. The response code from the server was 401 which means you are unauthorised. Upon this error, it was also failing to re-authenticate. The error codes can be seen in the documentation here - https://monzo.com/docs/#errors.

If I run across the error again, I'll get some more debugging information added in to see what is actually happening in the long term.

Minimal code snippet below to see when it was happening:

from ConfigParser import ConfigParser
import pymonzo

conf = ConfigParser()
conf.read('api_info.conf')
data = dict(conf.items('monzo'))

api = pymonzo.MonzoAPI(client_id=data['client_id'], client_secret=data['client_secret'])
@pawelad
Copy link
Owner

pawelad commented Sep 24, 2017

Looking at the source code of requests-oauthlib and oauthlib I think you may be right and in some cases Monzo API could return 401 without TokenExpiredError being raised.

@pawelad pawelad added the bug Something isn't working label Sep 24, 2017
@pawelad pawelad added this to the v0.10.1 milestone Sep 24, 2017
@pawelad pawelad changed the title Failed to get data when Re-authenticating Monzo API HTTP 401 response didn't trigger token refreshing Sep 24, 2017
@pawelad pawelad self-assigned this Sep 24, 2017
@pawelad
Copy link
Owner

pawelad commented Sep 24, 2017

Related: #5 (comment)

@pawelad
Copy link
Owner

pawelad commented Sep 24, 2017

This should be resolved in v0.10.1

@pawelad pawelad closed this as completed Sep 24, 2017
bartonp added a commit to bartonp/pymonzo that referenced this issue Sep 30, 2017
* upstream-master:
  Flake8 fixes
  Fixed failing '_refresh_oath_token' test
  Updated '_refresh_oath_token' to automatically replace existing token
  Fix Coveralls intergration
  Dev version bump
  Prepare release v0.10.1
  Updated Tox config file
  Try to refresh token if API request returned HTTP 401 (pawelad#6)
  Update Travis config file

# Conflicts:
#	src/pymonzo/monzo_api.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants