Forum Discussion

wleaom's avatar
Occasional Visitor
5 years ago

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')
    //so i validate the user and answer in response with the jwt token
    res.json({ access_token: jwt});


No RepliesBe the first to reply