I have {error: "Unauthenticated."}
when GET /api/user
headers:
Accept:application/json
Authorization:Bearer 16dd63d4ba079478273850acac2fd1a9c9d46ee26dba31a8b12cc3ffbbbe871f7e742fef6c1f492a
...
SELECT * FROM oauth_access_tokens
16dd63d4ba079478273850acac2fd1a9c9d46ee26dba31a8b12cc3ffbbbe871f7e742fef6c1f492a 1 1 Site [] 0 2016-08-28 21:45:07 2016-08-28 21:45:07 2116-08-28 21:45:07
and catch OAuthServerException
OAuthServerException {#196
-httpStatusCode: 401
-errorType: "access_denied"
-hint: "The JWT string must have two dots"
-redirectUri: null
#message: "The resource owner or authorization server denied the request."
#code: 9
#file: "/home/vagrant/code/givman/vendor/league/oauth2-server/src/Exception/OAuthServerException.php"
#line: 165
League\OAuth2\Server\Exception\OAuthServerException: The resource owner or authorization server denied the request. in /home/vagrant/code/givman/vendor/league/oauth2-server/src/Exception/OAuthServerException.php:165
Stack trace:
I have the same problem. How do you solved it?
I get the same problem. How did you solve it? Thanks!
Same here
omg I feel so ashamed... I was copy pasting just a part of the token and not all of it.
cc @urizev @novs
OMG!! 😵😵😵
Same for me!! Double click selection and and my stupidity...
At least I hope it helps other people
Thanks @dimsav.
I’m having the same issue, and I’m copying the access token properly.
Write tests to be 100% sure
"The JWT string must have two dots" for me too :-/
I just use the same encrypted string to decryption
wtf. same me. token didn't copied completely :open_mouth:
Ha ha, after almost 2 days of researching ... same here 😵 ...
The same for me
Has anyone managed to solve the problem? In my case some users access and others do not
@ViniciusBabugia the problem was just mistake on copy token.
I did copied it completely and the error is still there.
https://github.com/laravel/passport/issues/349
Dismiss my comment. I was sending the Authentication header and it's not needed with CreateFreshApiToken feature. That was it.
btw: there's a nice learning tutorial by Taylor here: https://laracasts.com/series/whats-new-in-laravel-5-3/episodes/13
OMG i use refresh token instead of access token. that's my mistake
If you send Authorization header when it's not needed it will fail.
I am also getting the same error "OAuthServerException" but i know this is because of access_token expired. My question is how do i convert OAuthServerException into an json response for api in laravel.
Any one please tell, How to solve it?
Thank you!!
@anususmi you can handle it on app\Exceptions\Handler.php
@goDamri Thank you, this helps me a lot. But in backend there was an Exception.
local.ERROR: The resource owner or authorization server denied the request. {"exception":"[object] (League\OAuth2\Server\Exception\OAuthServerException(code: 9): The resource owner or authorization server denied the request. at /home/www/testproject.com/vendor/league/oauth2-server/src/Exception/OAuthServerException.php:173)
[stacktrace]
I want to catch this exception, because this Exception always comes when the access_token expired.
Can you also please help me to solve this..
@anususmi use dontReport to exclude exception of OauthServerException being logged
Wow, it works. Thank you for your support @goDamri
Anyone help me about this issue...... Refresh token code in laravel 5.5 #793
In my header there is HTTP/1.0 and in the splitJwt it explodes the header by dot. and guess what!
I solved it in my case! my issue was when I was decoding the token, I was passing the whole header to the function. So What I did, got the content of the header, json decoded, got the token value from it and passed it to the lexik jwt decoder.
Most helpful comment
Ha ha, after almost 2 days of researching ... same here 😵 ...