Forum Discussion

aalili's avatar
aalili
Occasional Visitor
3 years ago

Executing API endpoint with Authorization from Swagger UI throws error 401

Hi,

 

I am having trouble executing endpoint from Swagger UI with bearer authorization.

 

I am using OpenAPI 3.0 specification and I define securitySchemes as 

 

"securitySchemes": {
 "bearerAuth": {
 "type": "http",
 "scheme": "bearer"
 }
}

 

 

And then append bearerAuth for all endpoints as 

 

 

"security": [{
 "bearerAuth": []
}]

 

 

Authorize button is shown on Swagger UI and I can fill the token, when I run the request I see 401 error on network, but, the curl is created correctly with the Authorization header and the right value. When I copy-paste that curl into my terminal, it works good.

 

Anyone faced similar issue?

1 Reply

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    What is the error message in the browser console? (Right-click the web page > Inspect > Console tab.)