REST API Authentication methods

Hi,

I have a plugin in Jira that i created.

Some of the functionality is, that i use HTTP requests (GET, PUT, POST) from Jira to Bitbucket and Bamboo.

For example:

public JSONObject checkForStgPrdDiff(String project, String repository, String from, String to) throws Exception {
    OkHttpClient client = new OkHttpClient();
    Request request = new Request.Builder()
            .url("https://stash.checkpoint.com/rest/api/1.0/projects/"+project+"/repos/"+repository+"/compare/commits?from="+from+"&to="+to+"&limit=10000")
            .get()
            .addHeader("authorization", "Basic " + myCredentials)
            .addHeader("content-type", "application/json")
            .build();

    okhttp3.Response response = client.newCall(request).execute();
    JSONObject jsonObject = new JSONObject(response.body().string());

    return jsonObject;
}

The things is, that i am not the only person in my company uses this plugin.

So by putting my credentials in the function, the other users get the data by login using my credentials (behind the scene).

Is there a way to perform HTTP request with authentication in a different way?

A way that will connect to Bitbucket and Bamboo using each user credentials and no my?

Thanks,

Nir

There is a way, you’ll have to use authentication token generated by bitbucket or bamboo for that user. How to get access to that (maybe this link will get you in the right direction) -