Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unauthorized requests on swagger #34

Open
gustavo-oliveira-mendonca opened this issue Sep 14, 2019 · 0 comments
Open

Unauthorized requests on swagger #34

gustavo-oliveira-mendonca opened this issue Sep 14, 2019 · 0 comments

Comments

@gustavo-oliveira-mendonca

I follow the instructions provided on the docs folder of the nestjs-angular bundle to test the api using <api_url>/swagger. First I made a POST to /api/auth/login and got a token. I then set the authorization by the button located on the top right of the page using the format Bearer <token>.

All the attempts to access locked paths on the api returned me error 401 - Unauthorized with the body:

{
  "statusCode": 401,
  "error": "Unauthorized"
}

Analyzing the post, swagger was sending on the header of my requests with the key Authentication: Bearer <my-token>. I believe the correct is Authorization: Bearer <my-token>.

I changed .addBearerAuth('Authentication', 'header') to .addBearerAuth('Authorization', 'header') on the main.ts from the backend project and got it working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant