Forge long background action

Dear community,
My addon includes a user custom action in the UI (sending a request) that calls a forge function. Is there a way this forge function can then call my back-end (hosted on my server), giving it tokens (access and refresh) to be able to call Jira to collect info about my customer’s tickets ? Knowing this collection / analysis task could take a while.

Thanks for your help.
Best regards

Hi,

You can use Forge Remote for such a situation; documentation is here: https://developer.atlassian.com/platform/forge/remote/

This will provide short lived tokens to your server (user or app tokens depending on your use case) to call back into the product or Forge.

Cheers
Ben

Hi Benny,
Thanks for your help. Unfortunately, the task to be performed on my server after a user request in Jira UI can take a long time, it’s an asynchronous process. I hope Forge Remote is able to provide access and refresh token so my backend can renew the token to use to request Jira.
Do you think it’s feasible or is there a maximum execution time ?

Best regards,
Sylvain

After a deeper look to Forge Remote, I see it can only send a request to my backend with one access token which expires quite quickly.
Options to get longer term tokens could be:

  • scheduled triggers
  • async events which allows longer timeouts
    Any advice on what is the most convenient solution ?

Hi Sylvain,

Really depends on your overall solution (hard to say with the limited information provided).

If you need a User token (asUser) your options are limited as it requires a customer interaction to spawn the user token. This will change with Act as User (impersonation) being actively looked at (follow the public roadmap for updates).

If you can use the App token (asApp), the options you mentioned above work, there is a third option available:

  • Call a Web Trigger that has a invokeRemote call → Passing back the App token.

Hi Benny,
Thanks for this third option.
To clarify, my app’s workflow is quite simple:

  • a user build a request in a Jira customUI then send it
  • I’d like my back-end to queue this request in some way
  • when a request is being processed, the service needs to collect some Jira tickets (could be a lot)
  • then custom UI will display some result

I hope you understand better why my back-end would need long term tokens (or with a renewal process) to collect these Jira data.

Which option does sound best then ?

Best regards,
Sylvain

Hi Sylvain,

As mentioned in my previous post; you are locked into requiring the User Token; which means you will have to use the front-end to remote resolver which gives you 2hr token.

If you need longer than that for your scenario; you will need to wait for the Act as User (user impersonation) feature. This will allow you to use Schedule trigger to Remote or Webtrigger to Remote and then impersonate the user you are after. The Feature is currently listed here: Log in with Atlassian account (Backend User Impersonation)

Good luck in building your app :smiley:

Cheers
Ben