Atlassian connect - calls to my app give error 401

Hi,

I have a macro with a custom macro editor view. In this editor I have to call back my app to return some parameters for a field.

I have a jquery ajax call that look like this:

ajax: {
	    url: '/content/search/?',
	    method: 'GET',
	    beforeSend: function(request) {
	    	var token = $('meta[name="token"]').attr("content");
	        request.setRequestHeader("Authorization", "JWT " + token);
	      }
...
}

The token get the values from a meta header that actually contains information:

<meta name="token" th:content="${atlassianConnectToken}"/>

If I inspect the network call it looks like this:

jwt

The end point method in my app has this signature:

@GetMapping("/content/search")
    public Response search(@AuthenticationPrincipal AtlassianHostUser hostUser,
    		@RequestParam(value = "title") String title) {
//...
}

Unfortunately it gives error 401

If I add @IgnoreJwt to the method in my app it works but of course I need to autheticate this call.

What am I missing?