question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@ApiBearerAuth() does not work on Method level

See original GitHub issue

image image As title said, the @ApiBearerAuth() decorator does not work properly on method level. It does work correctly on Controller level. The documentations states that the decorator can work on either Method or Controller level. I was just wondering if this’s a bug or I didn’t implement it correctly.

image Worked on Controller level

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
jiencocommented, May 22, 2018

I am having this issue again, using @nestjs/common 5.0.0, @nestjs/core 5.0.0 and @nestjs/swagger 2.0.0

5reactions
trileoucommented, Aug 22, 2019

@nartc I solved it by add this line to main.ts (or wherever you register nestjs-swagger) const options = new DocumentBuilder() .addBearerAuth()

image

But in your controller/method you also need to define @ApiBearerAuth()

Hope this help !!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to add Authentication to access to NestJS ...
Securing access to your Swagger with HTTP Basic Auth using NestJS with Express. First run npm i express-basic-auth then add the following to ......
Read more >
Bearer Authentication - Swagger
Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens.
Read more >
Custom decorators | NestJS - A progressive Node.js framework
An ES2016 decorator is an expression which returns a function and can take a ... Decorators can be defined for either a class,...
Read more >
Authentication with JsonWebToken in NestJS - Medium
JWT token authentication has become a de facto standard when it comes to ... body of the POST method that we will implement...
Read more >
Swagger - Midway.js
Open the component​ ... At this time, swagger components can also be automatically identified, and can also ... Do not add @ApiBody() decorator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found