inveniosoftware / troubleshooting

DEPRECATED - Use the forum instead:
https://invenio-talk.web.cern.ch
5 stars 4 forks source link

JWT: "The JWT token is not valid." #13

Open drjova opened 7 years ago

drjova commented 7 years ago

If you see an error related to JWT, make sure you are sending to any protected by require_api_auth endpoint the JWT token in the headers.

The token can be generated with two ways:

  1. In your Jinja templates you can use

either jwt()

<input type="hidden" name="authorization_code" value="XXX" />

or jwt_token() which will return just the token

XXX
  1. Programatically you can generate the token using the proxy current_accounts

from invenio_accounts.proxies import current_accounts

token = current_accounts.jwt_creation_factory()

By default the request headers to the protected API should include a Bearer Authorization

Authorization: Bearer xxx