How to implement authentication in Atlassian connnect spring-boot?

I am developing an Atlassian connect spring-boot addon. How to implement authentication? From the connect documentation I understand JWT is in-built in Connect libraries. But how to use this built-in feature? Please help.
Many thanks in advance.

If you are using atlassian-connect-spring-boot then you don’t have to implement authentication by yourself it’s already implemented by the framework you are using.
You should closely check documentation for the framework in the link above.

If you want to authenticate requests from the client that your add-on served then it’s alreadt done, only thing you need to do is include in your templates special variable that is provided by framework to render engine and it’s called atlassianConnectToken and pass it in authorization header when making request call with ajax or any other library (note that AP.request won’t work since it’s made for calls from client to host instance directly).

If you intend to make request from your add-on server to host instance of your client then you need to add AtlassianHostRestClients bean, which provides you with methods to make a request call to host instance

@Autowired
private AtlassianHostRestClients atlassianHostRestClients;

public void doSomething() {
    atlassianHostRestClients.authenticatedAsAddon().getForObject("/rest/api/example", Void.class);

All this info you can find in the link above in sections:

  • Responding to requests to an endpoint
  • Rendering views
  • Making API requests to the product as the add-on
  • Making API requests to the product as a user
  • Authenticating requests from iframe content back to the add-on

I highly encourage you to read all readme file for the project

1 Like

I am looking for more information regarding AtlassianHostRestClients apart from the code snippet you have mentioned.

Kinda hard to provide you with more information without knowing what you want exactly to do

I want to display bug count for a project in the JIRA instance. For this, I am developing an atlassian connect springboot add-on. For calculating bug count, I am calling exposed REST API which returns a JSON. How to authenticate my API requests?

If you are making your call from your client view just use request from AP module, you don’t need to do any authentication for that it will be made by AP.request module itself

What is AP.request, I am using spring boot not java script? How to achieve the same using spring boot?

I told that if you are making call from client side code.

Ooookay, let’s sort things out. first of all, which exactly rest api you are using, second of all, you want to show bug count to your users in jira right?

If rest api that you are calling contains bug count, then u don’t have to make call from your server, u can just make call to the same rest endpoint via java script in client code and show needed information as you wanted.

@prathyusha.gali, see my reply to your question in the thread How to make an API request using atlassian connect springboot with loggedin user credentials?.