I want to build Laravel rest api with Laravel Passport token. I generate access_token with my client secret key and I got the access token, but when I want to access the api with the access token always get message "exception 'BadMethodCallException' with message 'This token is not signed' in /vendor/lcobucci/jwt/src/Token.php:194". how to solve this error?

I've tried to generate new key, clear cache with php artisan cache:clear but not worked

This is my code to generate token 1. Generate access token with client secret key

Url : https://xxxxx/oauth/token

Parameter

{
    "grant_type":"client_credentials",
    "client_id":"41",
    "scope":"*",
    "client_secret":"CFprIY1qWznahoKDMomTAqLUx6IALfWR0xLwKjwA"
}

Response

{
    "token_type": "Bearer",
    "expires_in": 300,
    "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjIxYTg4NzQ2YmE1N2U5OGE3NDZlZDg5MmUyYjU3ZmZkOGFkNjJlYWZiMWNjMzk0MDU2NGQ1N2ZjZjE2MDcwYzFjMjYwYTE1MGU1N2MzYzQyIn0.eyJhdWQiOiI0MSIsImp0aSI6IjIxYTg4NzQ2YmE1N2U5OGE3NDZlZDg5MmUyYjU3ZmZkOGFkNjJlYWZiMWNjMzk0MDU2NGQ1N2ZjZjE2MDcwYzFjMjYwYTE1MGU1N2MzYzQyIiwiaWF0IjoxNTU3NzMzMzc2LCJuYmYiOjE1NTc3MzMzNzYsImV4cCI6MTU1NzczMzY3Niwic3ViIjoiIiwic2NvcGVzIjpbXX0.GGKOd-WRBT-UNmdDJe2WdUmatrumbwlDLlP0f1LKrAikU3JhwG8xkD4iLDUwmcaT5S37-GUSrdWjI3nnzNkAyFexLLJH7Vr6n7QsskWLH80ZR5mTaFXLgmsprp15UeoXm3op52Pa-Hq2mqx3C_nxQNxLElF68obApVhuYDLd2u46YP0b_DoYJqqg85sLGHyUsC95ofkMytmMc_aVoiOS1UmAoSn597p5ovJ3F47MakyuezduBvFWlA4wKxsW1wHjRe_4AkldzGhif16p_lbdBNg2HR-zQXYkmMHBjqLUd17R3w7fyOi5C_Z02gEkH78KqPP2KcbdJWhneLM_MpzkdYpTZVAI-F3NmCG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4vxGBS-abtrBQmRfU-jNgmTvkcVHSAWyycLKY8NiRUmWwFHly-IfviWxDnOEOYVDzY5ZaP0TGapZRpQEVBW12QauGtlxZ76NOxb9RZVX_dTgfXvS22icGW0XJPPM8eobYeyzwZvpBovBnCxJxKp_EgJZPeTG1bBzwderp1b3OXNc2gF_U2iUAxAIMohKKAe0JFzNe0bmsueQOLul8jc9ZjxP2Km2a5OHxnvTK_5dBWFN62yuGkJb8JJz5U5beUTbIaPPmJqu7n8rqyz3E5IGmxQUH0XES_ZMayMrvwI03PLQVmtngCb2MeOZjxRll3GtJGlpXYhoTPCeyQz7m-VWaCkNgfohEtt-1W7tGU8X_sMwNwyKRhzjM
[{"key":"Accept","value":"application/json","description":"","type":"text","enabled":true}]

Result : development.ERROR: exception 'BadMethodCallException' with message 'This token is not signed' in /xxxxxxvendor/lcobucci/jwt/src/Token.php:194

1 Answers

0
Sethu On

I think you've missed the traits HasApiTokens in User.php

Please add the traits like below

use HasApiTokens,Notifiable;