Ask a Question

Executing API endpoint with Authorization from Swagger UI throws error 401

aalili
Occasional Visitor

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.

 

swaggerexample.png

Anyone faced similar issue?

1 REPLY 1
HKosova
Moderator

Re: Executing API endpoint with Authorization from Swagger UI throws error 401

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


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: