Any ideas how to use token without 3-part key, splitted by dots?
Now i get error: JWT must have 3 parts
How can i use such tokens (for example): 833ec1ca1a47b128634a4744343a6215
Your token must be in the format of JWT. You are probably using incorrect token format.
Check this out: https://jwt.io/
this does happen when you try to send the AccessToken from Auth0 as a bearer authentication header.
Does this mean we can't use this library to send Auth0 access tokens as bearer?
cfr https://auth0.com/docs/api-auth/why-use-access-tokens-to-secure-apis
@DavidDecraene From the article you referenced:
The id_token is a JWT and is meant for the client only.
The access_token can be any type of token (not necessarily a JWT) and is meant for the API
Based on that, I'd assume that you are not supposed to use your access_token in Angular application
Actually they are saying I should NOT be using the JWT id_token but rather need to use the opaque non JWT access_token for all requests
For example, when retrieving the user profile you pass the access_token as a bearer
E;g;
Authorization: Bearer 833ec1ca1a47b128634a4744343a6215
I would wait for @chenkie to chime in, but it seems to me that in this case client is your server and API/server is Google or Auth0. The access token is what your server sends to Google to read your appointments, and the id_token is what you send to your server to say who you are.
You might also use the access token to refresh your id_token, but I'm not that familiar with Oauth2 or OpenID. I know JWT, SAML and OAuth1
@DavidDecraene your access token needs to be a JWT for use with your API. Here's a sample (with a Node backed) that shows how to do this with Angular: https://github.com/auth0-samples/auth0-angular-samples/tree/master/04-Calling-API
Please note that access tokens are not meant to be decoded on the client side and thus you shouldn't use tokenNotExpired for that purpose. The sample linked above uses the expiresIn value that comes back after authentication is complete to set a time at which the user should be considered unauthenticated.
The problem arises due to an improper storage of the token in the localStorage. While saving the token in the localStorage aslocalStorage.setItem('id_token', token); , now the latest change in angular has modified that to accept a default value of "token" instead of "id_token", so just change "id_token" to "token" everywhere in the setItem and getItem commands (eg. localStorage.setItem('token', token); ), and that should most probably solve your problem.
rename - id_token to token in all places
I have same error. I solve this this error.
Create new API in auth0. give Unique Identifier name. I took "NodeAPI"
I mention below config code.
auth0 = new auth0.WebAuth({ clientID: 'Hg3EhAWKgrPrX5UNGqFQA5vTbVGWF', domain: 'xyz.auth0.com', responseType: 'token id_token', audience: 'NodeAPI', redirectUri: 'http://localhost:4200/callback', scope: 'openid' });
Happy to help you
@DavidDecraene I am stuck in the same scenario just like you have mentioned above, were you able to resolve and find an answer.
I have to send access_token to my backend (where my backend uses auth0 client library to get my profile information. Since I cannot use the id_token to retrieve profile information and access_token cannot be sent through header of my request due toJWT must have 3 parts
I am clueless of what need to be done to resolve this issue. Can anyone help me on this, Thanks!!
@KeshShan it sounds like you are getting an opaque access token whereas what you need is a JWT access token. Have you followed the Calling an API quickstart?
@chenkie Thank you for that quick response, that helped!!
Most helpful comment
The problem arises due to an improper storage of the token in the localStorage. While saving the token in the localStorage as
localStorage.setItem('id_token', token);, now the latest change in angular has modified that to accept a default value of "token" instead of "id_token", so just change "id_token" to "token" everywhere in the setItem and getItem commands (eg.localStorage.setItem('token', token);), and that should most probably solve your problem.