How do I access the clientKey from the JavaScript API?

Hi, I am creating an add-on that syncronizes data between JIRA and another project management system.

I need a way to connect the JIRA instance with the correct instance of the other project management system after the add-on has been installed so it knows which data to syncronize.

I was planning on adding a postInstall page to the add-on and then have the user submit a UUID key on that page which I could use together with the JIRA clientKey to match the instances.

The problem is I can't figure out how to access the clientKey with the JavaScript API. I have looked through the AP object and found nothing.

How do people normally connect accounts between JIRA and systems

2 answers

Hi Niels,

clientKey is something you can only access during the add-on instalation handshake. It is up to you to save it (along with other installation data, like shared secret) so that your add-on can use it afterwards. You will need to have some sort of a backend to do that (you cannot do that with the static add-on approach). In order to understand how the installation handshake works, I'd suggest reading up on the Authentication section in Atlassian Connect documentation.

Once you saved the installation data, you can then get the clientKey with an ajax call, but then again you'd probably want to keep the mapping between JIRA and the other system in your backend code, so there should be no need to expose it to your frontend (JS) code.

Best regards,

Maciej

Hi,

I do a custom thing for our own use, not a plugin but wonder if this helps:

I use the AJS object with a custom ajax call to another services API to do something similar from two different JIRA servers.

With jquery:

AJS.$.ajax({
url: 'path/to/api',
data: AJS // or send part needed AJS.node.array[0].example
// other options ...
});

https://developer.atlassian.com/jiradev/jira-platform/jira-architecture/jira-templates-and-jsps/adding-javascript-to-all-pages-for-google-analytics

You can put it in the header jsp inside HTML script tags.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,813 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot