cancel
Showing results for 
Search instead for 
Did you mean: 

How use Authrozation Field on Header with GET Swagger-UI

Highlighted
Occasional Visitor

How use Authrozation Field on Header with GET Swagger-UI

I have a endpoint to authenticati

I have a endpoint to authenticate the users. This endpoint is a GET Method what receive the user email and password on Header in Authorization field. This endpoint responses with JWT token. So my header contains:

Authorization Basic "some codificated string on base64"

Then i get the Authorization value, the "some codificated string on base64" and decode to a normal string with value1:value2, where value1 is the user email and the value2 is the password.

So how i do this on the swagger file to can authenticate user and get my jwt token?

My app is nodejs and is:

app.get('/login', (req, res) => {
    const hash = req.headers.authorization.split(' ')[1];
    const [mail, password] = Buffer.from(hash, 'base64')
      .toString()
      .split(':');
    //so i validate the user and answer in response with the jwt token
    res.json({ access_token: jwt});
});

 

Tags (1)