I am trying to do a basic auth to Jira, but i keep receiving the error 403 forbidden.
My code is :
package br.com.indra.jiraauto.authentication;
import static java.lang.System.out;
import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
public class authentication
{
public static void main(String[] args) {
//code
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("username", "password");
provider.setCredentials(AuthScope.ANY, credentials);
HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
HttpResponse response;
try {
response = client.execute(new HttpGet("https://localhost:8080/rest/api/2/issue/project-1"));
int statusCode = response.getStatusLine().getStatusCode();
out.println("Response Code :"+ statusCode);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}