-
Notifications
You must be signed in to change notification settings - Fork 784
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
"The JWT string must have two dots" #349
Comments
Tried with base64 decode and passed from this:
to this:
So, it looks decoded. But not a valid JWT token. Not sure what to do. Can't get passport to work and there are a lot of threads out there with the same issue. And it's funny, but some of the said the solved it copying the token right (like, the were copying the cookie from the browser and it was cut, but it's not my case). |
I keep trying. So, the three dots does exists. I was getting them in the wrong way, using PHP $_COOKIE instead of Laravel helpers. This is what I'm trying to do:
And then, I configure ajax request for angularjs like this:
The error now that I get the correct JWT token is: 'Access token could not be verified' So, can't get passport to work but the error changed so I think we should close the issue. Any clue is welcome anyway. |
FYI: CreateFreshApiToken calls Laravel\Passport\ApiTokenCookieFactory to generate the JWT token. And as far as I understand it uses "HS256" algorithm (see Firebase\JWT class, line 153). Then, when receiving a new request with the Bearer auth token, we get into: BearerTokenValidator class. Line 52:
That verification fails. See: Class /vendor/lcobucci/jwt/src/Token.php line 191
That method returns false. And if I compare the algorithms with a var dump I get: So, Passport with CreateFreshApiToken wont work for me. Don't know why! |
Nevermind. I knew I was over-complicating something. There's no need to send 'Authorization' header using CreateFreshApiToken feature. There's a nice tutorial here btw: https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13 |
I can't get authorized with "CreateFreshApiToken" feature. I get: "The resource owner or authorization server denied the request.". So I researched a little.
Basically, League's OAuth2 BearerTokenValidator keeps complaning that "The JWT string must have two dots".
And it's true. A JWT token must have dots to concatenate the three component parts: header.payload.signature
The Passport docs says: "This cookie contains an encrypted JWT". So, I get it, you are encoding the JWT somehow. But then, how can I do in js to decrypt that? I'm not using Vue.js, So I write my own authorization headers passing the "encoded JWT token". And as far as I see, Passport is not performing that decoding step.
The text was updated successfully, but these errors were encountered: