Skip to content

request options should be supported instead of oauth, username, password, & proxy constructor parameters #152

Description

@llecaroz

Hi,
I am playing with you class & you might not defnitly play with proxy, username, passwords, & others authentication scenarios. Instead of that you should accept a requestOptions parameter in the constructor, allowing the caller to set request options independently/whatever the login scenario to be added (the same for username/password)

For example, by that way, the caller can add extra header request parameters like proxy authentication or whatever.

As example of code from the caller (here the last parameter is the options map you give @ the request method. In that example, I connect to an authenticated proxy & sigin also in jira:

var username = 'username';
var password = 'password';

JiraApi = require('./jira.js').JiraApi;

const HttpProxyAgent = require("http-proxy-agent");
var jira = new JiraApi('https', 'hostname', 443, '2', true, false, null,{
       "agent": new HttpProxyAgent('http://proxyserver'),
        headers: {
            "Proxy-Authorization": 'Bearer myproxycredentialtoken'
            "Authorization": 'Basic ' + Buffer.from(username + ':' + password).toString('base64')
        }
    });
console.log(jira.searchUsers(username, 0, 50, false, false, function(error, string) { console.log(error) }));

Next you will have to concatenate/transfer that map into your own options
This will really make your class more opened, extensible & easier to maintain on that point for you.
Best regards
Louis

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions