Swagger: Preserve auth token in localStorage

Created on 17 Apr 2018  路  7Comments  路  Source: nestjs/swagger

Hello, currently after pressing the authorize button JWT token sent along with requests until a user refreshes a page.

After each page refresh user should authorize again.

I think it's a bug and _token should be saved in localStorage_ or sessionStorage (for security reasons).

But at least I want to have a checkbox "remember me" in authorization modal window so I can easily use just Swagger without any additional tools like Modheader.

Most helpful comment

if anyone still need a simple solution:

  SwaggerModule.setup('api', app, document, {
    swaggerOptions: {
      persistAuthorization: true,
    },
  });

All 7 comments

Hi @oleksii-shnyra,
This is rather a feature request to the underlying swagger-ui-express library.
Same as in #73

if anyone still need a simple solution:

  SwaggerModule.setup('api', app, document, {
    swaggerOptions: {
      persistAuthorization: true,
    },
  });

if anyone still need a simple solution:

  SwaggerModule.setup('api', app, document, {
    swaggerOptions: {
      persistAuthorization: true,
    },
  });

Does this solution work for Swagger's BearerAuth, based on my testing this doesn't work.

if anyone still need a simple solution:

  SwaggerModule.setup('api', app, document, {
    swaggerOptions: {
      persistAuthorization: true,
    },
  });

Does this solution work for Swagger's BearerAuth, based on my testing this doesn't work.

yep

@sagic Thanks. It works fine.

if anyone still need a simple solution:

  SwaggerModule.setup('api', app, document, {
    swaggerOptions: {
      persistAuthorization: true,
    },
  });

Does this solution work for Swagger's BearerAuth, based on my testing this doesn't work.

Took my one reload to understand that it then works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fiorello picture Fiorello  路  5Comments

kalaivanan-muthusamy picture kalaivanan-muthusamy  路  4Comments

vh13294 picture vh13294  路  4Comments

alisherks picture alisherks  路  4Comments

cdiaz picture cdiaz  路  4Comments