wcandillon / swagger-js-codegen

A Swagger Codegen for typescript, nodejs & angularjs
Apache License 2.0
693 stars 286 forks source link

Basic Auth Support #76

Open indolering opened 9 years ago

indolering commented 9 years ago

Does the Node.js template support basic auth? It looks like it only accepts API tokens....

wcandillon commented 9 years ago

No it is not supported. However you might be able to use basic auth using global options https://github.com/request/request#requestdefaultsoptions of the request module?

indolering commented 9 years ago

True, although I would prefer to use Popsicle since I am deploying to the browser.

Contagious06 commented 9 years ago
        if (this.token.isQuery) {
            queryParameters[this.token.headerOrQueryName] = this.token.value;
        } else if (this.token.headerOrQueryName) {
            headers[this.token.headerOrQueryName] = this.token.value;    
        } else {
            headers['Authorization'] = 'Bearer ' + this.token.value;
        }
new YourClass({
    token: {
        value: 'Basic ' + encode(username + ':' + password),
        headerOrQueryName: "Authorization"
    }
});