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

Unhelpful error when using wrong api_secret_key #20

Open
puntium opened this issue Jul 15, 2020 · 1 comment
Open

Unhelpful error when using wrong api_secret_key #20

puntium opened this issue Jul 15, 2020 · 1 comment

Comments

@puntium
Copy link

puntium commented Jul 15, 2020

βœ… Prerequisites

  • [ x] Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
  • [ x] Are you running the latest SDK version?
  • [x ] Are you reporting to the correct repository (magic-admin-python)?

πŸ› Description

Was building some code to pull user email out of a token passed from a client in a flask app.

Read the docs wrong and set api_secret_key to the public key for my app instead of the secret key.

When calling User.get_metadata_by_token, I got this trace:

Traceback (most recent call last):
File "/home/ken/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/ken/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ken/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/ken/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/ken/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ken/.local/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/ken/flask_test/app.py", line 26, in register_magic_token
response = magic.User.get_metadata_by_token(token.encode('utf-8'))
File "/home/ken/.local/lib/python3.8/site-packages/magic_admin/resources/user.py", line 19, in get_metadata_by_token
return self.get_metadata_by_issuer(self.Token.get_issuer(did_token))
File "/home/ken/.local/lib/python3.8/site-packages/magic_admin/resources/user.py", line 11, in get_metadata_by_issuer
return self.request('get', self.v1_user_info, params={'issuer': issuer})
File "/home/ken/.local/lib/python3.8/site-packages/magic_admin/resources/base.py", line 44, in request
return self._request_client.request(
File "/home/ken/.local/lib/python3.8/site-packages/magic_admin/http_client.py", line 96, in request
return self._parse_and_convert_to_api_response(
File "/home/ken/.local/lib/python3.8/site-packages/magic_admin/http_client.py", line 120, in _parse_and_convert_to_api_response
raise error_class(
magic_admin.error.BadRequestError:

Would be nice to have a better error message here. Can the the Magic() constructor call validate that it's getting a private key?

magic-admin 0.0.4, python3, Ubuntu 20.04

@FYJen
Copy link
Contributor

FYJen commented Aug 13, 2020

@puntium: Thanks for reporting this. I think it will be a good improvement to add a quick validation on the API key. We will add that in for our next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants