Loosing jira context after loading new page in iframe

I have several pages in my addon, “home” page works pretty well:
it loads first, having Jira context and i have no troubles with recognizing the user and making rest api requests for him. But when i load new page in frame (target="_self") it looses Jira context, any request made from that page has zero Jira parameters and my server can’t recognize a user.

I checked another addons in marketplace and they also load pages in frame just via url, and they don’t loose context. What i’m doing wrong?

UPD. I steel can get JWT token using js API, but what i should to to have all requests made from second page to have at least jwt token in parameters?

You’ll need to generate a jwt token or something to pass down to the next page(is pass it on the query string from the first page). If you’re using ACE you can do this through the token property.

I’m building app using .Net Framework. So i need to generate jwt token before redirecting user to new page and add it to query string parameter? It’s just not really clear for me why should i do it if i can get jwt directly from Jira while i’m handling redirect request, but when user appears on new page i don’t get any parameters with new requests.

Maybe i can somehow say jira to handle new page via JavaScript AP object? When i call AP.context.getToken() on new page i can get jwt token. I looked through js api documentation here:
and found that it’s not describing whole AP object, and some examples are returning undefined.

UPD: I added jwt token to parameters before sending request to load new page and it done almost nothing. I got this token on server side and got user data from it, but any way after loading new page in frame i steel don’t get any Jira parameters on requests.

Do you mean that i should not rely on jira parameters and i should add jwt token on client side to every request made to my server “by hand”?

AP.context.getToken() is for cacheable iframes: https://developer.atlassian.com/cloud/confluence/cacheable-app-iframes/

If you’re going the cacheable iframe (and not putting any user/tenant specific info on the query string/path) - you’ll still need to have the all.js on all of the pages. That should set up the AP bridge so that you can get hold of the data on the javascript side.

If you’re not using the Cacheable iframes, then you’ll need to pass the data on the query string when you link to things - however this is when you’ll need to put the jwt string on the query string (or some other security approach).

Decided to load page in “_top” target to not to deal with jwt tokens on client side.
Using next declaration in atlassion-connect.json file: "url": "/{ac.controller}/{ac.action}?id={ac.pageid}", for now the best solution i found.
Thanks for help.