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

JWT must have 3 parts #32

Closed
Steven-Harris opened this issue May 25, 2017 · 26 comments
Closed

JWT must have 3 parts #32

Steven-Harris opened this issue May 25, 2017 · 26 comments

Comments

@Steven-Harris
Copy link

I am getting the following error and I am not quite sure how to debug/fix it. Thoughts?

Error: JWT must have 3 parts
    at JwtHelper.decodeToken (angular2-jwt.js:236) [angular]
    at JwtHelper.getTokenExpirationDate (angular2-jwt.js:246) [angular]
    at JwtHelper.isTokenExpired (angular2-jwt.js:255) [angular]
    at tokenNotExpired (angular2-jwt.js:274) [angular]
    at AuthHttp.requestWithToken (angular2-jwt.js:107) [angular]
    at DeferSubscriber.factory (angular2-jwt.js:146) [angular]
    at DeferSubscriber._callFactory (DeferObservable.js:92) [angular]
    at DeferSubscriber.tryDefer (DeferObservable.js:85) [angular]
    at new DeferSubscriber (DeferObservable.js:81) [angular]
    at DeferObservable._subscribe (DeferObservable.js:71) [angular]
    at DeferObservable.Observable._trySubscribe (Observable.js:57) [angular]
    at DeferObservable.Observable.subscribe (Observable.js:45) [angular]
    at MapOperator.call (map.js:54) [angular]
    at Observable.subscribe (Observable.js:42) [angular]
@chenkie
Copy link
Contributor

chenkie commented May 25, 2017

it sounds like you probably have an opaque access token in local storage instead of a JWT. Can you check what you have for your access_token?

Which sample are you trying? Have you configured your audience to use your API identifier?

@Steven-Harris
Copy link
Author

Hey @chenkie thanks for your help, I have verified that the audience is correct and my api that has the same audience is working.
I am unfamiliar with checking the access_token. What should I do to check it?

Thanks,

@chenkie
Copy link
Contributor

chenkie commented May 25, 2017

You can check for the token in local storage in dev tools, assuming you're storing it there as is done in the sample :) Basically we want to check whether the access token is a short string or whether it is a JWT which will be much longer.

@Steven-Harris
Copy link
Author

Ok, I looked at my access_token in localstorage and you suspected right. The access token is a short string about 14 characters

@Steven-Harris
Copy link
Author

What do I need to do to set the access_token with the JWT one?

I am using the same pattern as example 1

 localStorage.setItem('access_token', authResult.accessToken);
 localStorage.setItem('id_token', authResult.idToken);

@chenkie
Copy link
Contributor

chenkie commented May 25, 2017

those are the correct lines. The access_token you get back will either be a 14 char string like that, or a JWT. It's a JWT if you have a valid audience set as your API identifier.

What do you have set as your audience?

@Steven-Harris
Copy link
Author

Steven-Harris commented May 25, 2017

I have the following in my auth0.WebAuth object
audience: 'https://api.stevenharrisdev.com',
and this matches what I have on my api and the auth0 dashboard

@chenkie
Copy link
Contributor

chenkie commented May 25, 2017

Hmm you should be getting a JWT then. Maybe try creating another test API in Auth0 and see if anything changes. Otherwise we'll probably need to route you to support and get you to send in a HAR file.

@Steven-Harris
Copy link
Author

Is there any way I can get a jwt token as my access_token or is there a reason I am not? I have a jwt for my id_token but not my access_token.

@chenkie
Copy link
Contributor

chenkie commented May 26, 2017

The id_token will always be a JWT. The access_token should be as well if you have your audience set to your API identifier. Did you try with a different (new) API? Also, just for good measure, try going to the OAuth settings for your client and make sure that the OIDC Conformant switch is flipped to on.

@Steven-Harris
Copy link
Author

oh ok,
Yeah I tried with a new api and it didn't do anything different. Let me check the OIDC Conformant. - This is configured in Auth0 settings page right?

@Steven-Harris
Copy link
Author

Ok "OIDC Conformant", was not turned on but I need to figure out how to fix my call back after I login. It is redirecting to my oauth domain and not my localhost for some reason.

@chenkie
Copy link
Contributor

chenkie commented May 27, 2017

What do you have set as your callback?

I should have asked earlier, but are you using Auth0Lock or auth0.js for your project?

@Steven-Harris
Copy link
Author

Steven-Harris commented May 27, 2017 via email

@Steven-Harris
Copy link
Author

Also I am running angular 4

@chenkie
Copy link
Contributor

chenkie commented May 28, 2017

Ah ok--do you have your callback route set as an Allowed Callback URL in your client settings?

@Steven-Harris
Copy link
Author

Steven-Harris commented May 28, 2017 via email

@chenkie
Copy link
Contributor

chenkie commented May 29, 2017

Ok, but you're getting a JWT access token now?

@Steven-Harris
Copy link
Author

Steven-Harris commented May 29, 2017 via email

@chenkie
Copy link
Contributor

chenkie commented May 29, 2017

Ok at this point it's probably best to send in a support request. It might be something specific to your account.

@Steven-Harris
Copy link
Author

Steven-Harris commented May 29, 2017 via email

@chenkie
Copy link
Contributor

chenkie commented May 29, 2017

Did you check https://support.auth0.com? If you have a plan that comes with support then you can open a ticket. Otherwise you can post something in the community form here: https://community.auth0.com/

@Steven-Harris
Copy link
Author

Ok I have restarted everything and created a clean copy of the embedded login branch..
I have the follow urls in the "allowed callback" and "allowed cors"

http://localhost:4200/#/login, http://localhost:4200/#/callback,
http://localhost:4200/login,
http://localhost:4200/callback,
http://localhost:4200/*

I am just getting "Cross origin login not allowed." every time

@Steven-Harris
Copy link
Author

CORS error is only happening on the custom login and not when using AuthLock

@chenkie
Copy link
Contributor

chenkie commented May 30, 2017

Any other details that come with the error? @luisrudge is there anything you can suggest we try given the cross-origin error?

@Steven-Harris
Copy link
Author

Steven-Harris commented May 30, 2017 via email

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

No branches or pull requests

2 participants