Hkm Sadek
Hkm Sadek

Reputation: 3209

Laravel jwt auth Token Signature could not be verified

I am facing a very strange problem. If I enter this following url in my browser it returns the user correctly

http://192.168.0.100:8000/app/getUser?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xOTIuMTY4LjAuMTAwOjgwMDBcL2FwcFwvbG9naW4iLCJpYXQiOjE1Nzk5NjAwMTcsImV4cCI6MjQyODU4ODAwMTcsIm5iZiI6MTU3OTk2MDAxNywianRpIjoiYlFiYXIyVEJIdVJNN1lUSCIsInN1YiI6MTcsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.KLsnS769zthfFWth5Z4BeWDP6K0zEQ5eTONpKdlJMbA

But if I send a get request from postman or my app, it gives me error like this

[2020-01-25 13:49:43] local.ERROR: Token Signature could not be verified. {"userId":17,"exception":"[object] (Tymon\\JWTAuth\\Exceptions\\TokenInvalidException(code: 0): Token Signature could not be verified. at /Users/mdzainalabedin/laravel/olvboxapi/vendor/tymon/jwt-auth/src/Providers/JWT/Lcobucci.php:137)
[stacktrace]
#0 /Users/mdzainalabedin/laravel/olvboxapi/vendor/tymon/jwt-auth/src/Manager.php(101): Tymon\\JWTAuth\\Providers\\JWT\\Lcobucci->decode('eyJ0eXAiOiJKV1Q...')
#1 /Users/mdzainalabedin/laravel/olvboxapi/vendor/tymon/jwt-auth/src/JWT.php(200): Tymon\\JWTAuth\\Manager->decode(Object(Tymon\\JWTAuth\\Token))


My function is this

public function getUserInfo(Request $request){
   \Log::info($request);
   return $user = JWTAuth::parseToken()->authenticate();
}

Both has valid same token but still gives different result. Any idea what could be wrong? Thank you.

Upvotes: 1

Views: 1092

Answers (1)

khashayar
khashayar

Reputation: 58

your question is unclear about how you pass the token using postman but i guess using the below method to passing the token would solve the problem:

Bearer
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC8xOTIuMTY4LjAuMTAwOjgwMDBcL2FwcFwvbG9naW4iLCJpYXQiOjE1Nzk5NjAwMTcsImV4cCI6MjQyODU4ODAwMTcsIm5iZiI6MTU3OTk2MDAxNywianRpIjoiYlFiYXIyVEJIdVJNN1lUSCIsInN1YiI6MTcsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.KLsnS769zthfFWth5Z4BeWDP6K0zEQ5eTONpKdlJMbA

Upvotes: 2

Related Questions