Getting the window URL for re-entry into app on oauth callback

I’m trying to integrate with a third party service using 3-legged oauth in my connect app. I can ‘break-out’ of Jira by setting = "3rd-party-auth-location", but I’m struggling with how to redirect my users back into my app after the callback.

Ideally I wanted to send users back to ‘wherever they were’ when they started the oauth flow, but I’m being foiled because while I can set the top location, the iframe is blocked from reading it.

I can always try and manually construct the appropriate URL, (e.g. https://<instance><location-in-app>), but that’s horribly hacky and seems liable to break.

I tried using AP.navigator.getLocation(), but it failed with no context function defined, even directly copying the example from the docs. In any case, it doesn’t look like it would return anything useful.

I feel like this must be possible from within the frame, as setting base:true on the atlassian all.js results in the top location being included in the injected <base> tag, but can’t see how it’s doing that.

I could do this by including the <base> tag (I don’t currently) and reading it out of there, but I really want to avoid it if possible because it seems I’d have to update all my URLs to be absolute, which is going to be pretty painful.

I know there are other apps doing the oauth dance and redirecting back in, so must be possible somehow!

1 Like