atlassianConnectToken not found in model

I am developing a jira cloud add on. I am using spring boot.

Documentation states " Instead, add-ons can use the JWT self-authentication token - provided by atlassian-connect-spring-boot with each request in the model attribute atlassianConnectToken (also as deprecated atlassian-connect-token )"
I am using unirest.
Methods in controllers are looking like this:
@RequestMapping(value = “/get-something”, method = RequestMethod.GET)
public String getSomething(@AuthenticationPrincipal AtlassianHostUser hostUser, Model model) {

}

@RequestMapping(value = “/search”, method = RequestMethod.POST)
public String searchsomething(@AuthenticationPrincipal AtlassianHostUser hostUser, Model model, @RequestBody MultiValueMap<String, String> formParams) {

}

The org.springframework.ui.Model never contains any key"atlassianConnectToken" or the old one “atlassian-connect-token”.

The GET Method contains the AtlassianHostUser. as is the first call into the iframe.
However a form posts to the POST method and the AtlassianHostUser is null.
What I need is to get the AtlassianHostUser and my understanding of the Atlassian documentation is that the template(velocity) that contains the form who posts, should contain the meta tag with content atlassianContentToken. This should be obtained from the model. However the model never has such a key. I am assuming the model is the org.springframework.ui.Model .
This model contains the following keys: atlassian-connect-licence, atlassian-connect-timezone, atlassian-connect-all-js-url, atlassian-connect-locale.
But not the atlassianContentToken or the atlassian-content-token.

Found the solution myself by using spring boot version 2 and up.

1 Like