How to make an API request using atlassian connect springboot with loggedin user credentials?

I developed an addon in Atlassian connect springboot and trying to fetch some data using JIRA REST API. I want to know how we make rest API calls with currently logged in user credentials. How to make an API request using Atlassian connect spring-boot with logged-in user credentials? Any sample spring-boot projects that are making use of REST API?

Hi @it1,

this is described in the README sections Making API requests to the product as the add-on and …as a user, as well as in the Javadoc for AtlassianHostRestClients.

If you creating a project from the Maven archetype, those four lines of code - and declaring the appropriate scope in your add-on descriptor - should be all you need.

1 Like

public void doSomething() {
atlassianHostRestClients.authenticatedAsAddon().getForObject("/rest/api/example", Void.class);
What does the above method returns?
Is there any sample project on atlassianhostrestclients?

@prathyusha.gali, in your example, AtlassianHostRestClients#authenticatedAsAddon() returns a RestTemplate configured for providing JWT authentication to Atlassian hosts. getForObject() is called with Void.class as the return type and thus always returns null.

But RestTemplate is a Spring class with a large number of methods. Please consult the Javadoc for the class or the related tutorials for how to use it.

1 Like

What to do when bearer token expires