Authentication with bearer token

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 12, 2024

Hello

I am able to authenticate using Unirest library using email address and token.

Is it possible to just use bearer token and not have email address as part of authentication.

Postman authentication just uses bearer token to authenticate how can I do it using java program.

Please let me know.

The following program works using email and token.

package main;

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;

public class UniRestTest {

public static void main(String[] args) {

try {

HttpResponse<JsonNode> response = Unirest.get("https://xxx.atlassian.net/rest/api/3/issue/KAN-1")
.basicAuth("xxx@gmail.com", "ATATT3xFfGF00B16Long")
.header("Accept", "application/json")
.asJson();

System.out.println(response.getBody());

}catch(Exception e) {
System.out.println(e.getMessage());
}
}
}

 

0 answers

Suggest an answer

Log in or Sign up to answer