auth0 / angular-jwt

Library to help you work with JWTs on AngularJS
MIT License
0 stars 1 forks source link

How to encode to `abc.xyz.def` instead of Bearer #157

Closed opyate closed 7 years ago

opyate commented 7 years ago

I'm following this example: https://auth0.com/docs/quickstart/spa/angularjs/03-calling-an-api and the Authorization header looks like this:

Authorization: Bearer NzmWR9AfD40PEYfC

...but it is incompatible with the Python Flask backend example here: https://auth0.com/docs/quickstart/backend/python/01-authorization

...which expect the token to be in the abc.xyz.def shape.

How do I get angular-jwt to get the token into the said shape? I couldn't see an encode function anywhere (as opposed to the decode which accepts this shape).

chenkie commented 7 years ago

it looks like the issue is that you're getting an opaque access token instead of a JWT access token from Auth0. angular-jwt doesn't actually come into play for that since it's Auth0 that is issuing the tokens.

Can you open an issue here with some more description including your WebAuth configuration?

Thanks

opyate commented 7 years ago

Thanks for the reply!

I simply have to change this line to get id_token from localStorage instead of the opaque access_token: https://github.com/auth0-samples/auth0-angularjs-samples/blob/a28650bd2b6ce227f2ef73c5f9679c8bab1b4bb7/03-Calling-an-API/app/app.js#L65

chenkie commented 7 years ago

ID tokens aren't meant to be sent to APIs, you do need to send the access token. The issue is likely that API authorization for your app isn't configured correctly which is why you were getting an opaque access token and not a JWT. If you open another issue here we can figure out what's going on :)