Basic Auth header not sent (Swagger) -
i have basic auth secured api after filling in authentication credentials, not apply request header. saw"error server not found or error occurred " @ swagger editor , "401 unauthorized" on fiddler.
user name , pwd : odata , qtkr47ptm3pmzlyehnrw4dxhhgyjmfm3ckuzfxdn0tk=
here swagger json
{ "swagger": "2.0", "info": { "version": "1.0.0", "title": "basic auth example", "description": "an example how use basic auth swagger.\nserver code available [here](http://navm3.cloudapp.net:90/nav/odata). it's running on navm3.\n\n**you can use below user name , password test.**\n* user name: `odata`\n* password: `qtkr47ptm3pmzlyehnrw4dxhhgyjmfm3ckuzfxdn0tk=`\n" }, "host": "navm3.cloudapp.net:90", "basepath": "/nav/odata", "schemes": [ "http" ], "securitydefinitions": { "basicauth": { "type": "basic", "description": "http basic authentication. works on `http` , `https`" } }, "paths": { "/": { "get": { "security": [ { "basicauth": [] } ], "responses": { "200": { "description": "will send `authenticated` if authentication succesful, otherwise send `unauthorized`" } } } } }
}
i had same problem, problem in nodejs back-end.
if using nodejs, problem cors. should enable cors in nodejs express , work.
to enable cors in nodejs can add below code, before of routes.
var app = express(); app.use(function(req, res, next) { res.setheader('access-control-allow-origin', '*'); res.setheader('access-control-allow-methods', 'get, post, put, update, delete, options'); res.setheader('access-control-allow-headers', 'origin, x-requested-with, content-type, accept, authorization'); next(); });