adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
187 stars 65 forks source link

Authorization returns 401 error while passing bearer token #222

Closed YhomiAce closed 4 months ago

YhomiAce commented 11 months ago

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

RomainLanz commented 11 months ago

Hey @YhomiAce!

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

YhomiAce commented 11 months ago

sure, here is a link to the Repo

stale[bot] commented 7 months ago

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.

RomainLanz commented 5 months ago

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.

RomainLanz commented 4 months ago

Closing since no answer from issue reporter.