adonisjs/auth

Authorization returns 401 error while passing bearer token

YhomiAce opened this issue · 5 comments

Hi, I'm new to adonisjs, while trying to do authentication and authorization i keep getting stuck at the authorization stage.
Using the geneated token from login endpoint to authorize protected routes using auth middleware

the request returns 401 error

"errors": [
        {
            "message": "E_UNAUTHORIZED_ACCESS: Unauthorized access"
        }
    ]

This the log of the request I'm making from postman

{
  authorization: 'Bearer W29iamVjdCBPYmplY3Rd.C0k2FkyfaWalesRa92Vr-pkIHUc3vEkzRNEMFm3-p_oLg9B8XUBfQfc7qEBP',
  accept: 'application/json',
  'content-type': 'application/json',
  'user-agent': 'PostmanRuntime/7.29.3',
  'postman-token': '022a53d4-0a49-4d18-9ebd-e6feeff4d478',
  host: '127.0.0.1:3333',
  'accept-encoding': 'gzip, deflate, br',
  connection: 'keep-alive'
}
{ guards: [ 'api' ] } // i logged the guards

Is their a configuration I might be missing, I've read the doc and I seem to be doing everything as stated

Hey @YhomiAce!

Could you please create a repository with the minimum amount of code to reproduce your issue?

sure, here is a link to the Repo

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sorry for the delay. This issue has been last in my notification tab. 😅

I am not sure if you still have this issue, but I see that you are using an outdated version of @adonisjs/auth.
Please upgrade to ^8.2.3. It should fix it.

Closing since no answer from issue reporter.