-
Notifications
You must be signed in to change notification settings - Fork 19
Could not authenticate with provided credentials #40
Comments
Which version of |
I downgraded it to 1.0.0 |
Could it be this? Are you refreshing the tokens given to you?
Any example code snippet I can use to recreate this (please omit any sensitive data). |
I made a client as Confidencial with a redirect url to http://localhost/ and running it on an AWS inststance and it looks like monzo.json has a refresh token, I generate the monzo json file first with:
then I paste the code I get to:
which seems to work when I use this but only for a day or so
|
@NordineKB that is odd. Looking at the original trace you send, it looks like there's an issue with refreshing the token. I'll look into this for you. |
Many thanks 👍 @muyiwaolu |
@NordineKB just a heads up, still looking into this. I'm going to wait a day for the expiry on a test project I have and see if I can replicate your issue. |
@muyiwaolu Any luck replicating it? I've created a new confidential client and I got the same issue today |
Any news? I got a similar problem. |
@streetpunkpl Hi, yes I've figured out a way around it, I'll post my fix later today |
@NordineKB Thanks so much. It will help me a lot. |
Essentially in auth.py (https://github.com/muyiwaolu/monzo-python/blob/dev/monzo/auth.py) the way it requests tokens is wrong. I've had a look at the API documentation and it needs to be some thing like:
also I used urllib so need to add that to the top
This is a bit hacky and I'm sure someone can write a cleaner way of fixing it without pasting in the client secret. I might make a PR if I get the time to but this code fixed it for me :) |
Man send me your PayPal.me link if it's working I'm gonna tip you for ☕ :P I'm totally newbie on Python (totally don't understand oauth2 protocol) . Just playing around Monzo data, but it's quite anoying when I need refresh token every 30hours. |
@streetpunkpl Happy to help! let me know if it works for you |
@NordineKB Your fix works FLAWLESSLY! Thank you so much :)))) |
@NordineKB awesome fix! I'll integrate it when I get a chance, although I'm quite busy so a PR would be super appreciated! |
I've been using Auth2 method of getting tokens, once the generated monzo.json file was made I was using the following line of code which only works for like a day until I get the error below, has anyone had the same or know whats causing it?
oclient = MonzoOAuth2Client(client_id, client_secret).from_json()
client = Monzo.from_oauth_session(oclient)
["Traceback (most recent call last):
File "/home/ubuntu/.local/lib/python3.6/site-packages/monzo/auth.py", line 107, in make_request
self.session.request(method, url, data=data, **kwargs))
File "/home/ubuntu/.local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 330, in request
http_method=method, body=data, headers=headers)
File "/home/ubuntu/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "auth_test.py", line 24, in
balance = client.get_balance('acc_00009U1x5f20Agu9wEFoS9')
File "/home/ubuntu/.local/lib/python3.6/site-packages/monzo/monzo.py", line 132, in get_balance
response = self.oauth_session.make_request(url, params=params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/monzo/auth.py", line 110, in make_request
self.refresh_token()
File "/home/ubuntu/.local/lib/python3.6/site-packages/monzo/auth.py", line 160, in refresh_token
auth=HTTPBasicAuth(self.client_id, self.client_secret)
File "/home/ubuntu/.local/lib/python3.6/site-packages/requests_oauthlib/oauth2_session.py", line 309, in refresh_token
self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
File "/home/ubuntu/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 415, in parse_request_body_response
self.token = parse_token_response(body, scope=scope)
File "/home/ubuntu/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 425, in parse_token_response
validate_token_parameters(params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/parameters.py", line 432, in validate_token_parameters
raise_from_error(params.get('error'), params)
File "/home/ubuntu/.local/lib/python3.6/site-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidClientIdError: (invalid_request) Could not authenticate with provided credentials"](url)
The text was updated successfully, but these errors were encountered: