External Site to Access Confluence Cloud API via Ajax

Mike Poling March 8, 2017

Hello,

We have an external site on an external server that we would like to make calls to the Confluence-Cloud REST Api to return JSON data. Can I call our confluence cloud api's via Ajax from our external site? If so, how can I do this?

I have tried multiple ways but I either get CORS errors or possible authentication errors. All I want is to authenticate via anonymous user and (GET) read-only data back. How do I format this Ajax call?

Thanks,

Mike

2 answers

0 votes
James Dellow
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 8, 2017

You can, but you external site would need to do this using JWT https://developer.atlassian.com/static/connect/docs/latest/concepts/authentication.html

For client-side apps running in the browser, the all.js script creates the bridge to between your Confluence Cloud instance and your add-on. It won't work outside of Confluence.

Rob Jackson March 10, 2017

Hey James, could you elaborate on this a bit? Once we have a JWT, how do we utilize that so that our site can pull data? We're missing the steps on what we need to configure within Confluence itself (cloud version) so that the link is made. We've circled through dozens of pages of their documentation, but none of it ties together coherently how to actually do this from A - Z. Thanks for any assistance you can provide!

James Dellow
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 10, 2017

You need to install a private add-on into Confluence Cloud, just as you would install a 3rd party add-on from the Atlassian Marketplace, but that's the easy bit - based on your description, it would just be an add-on descriptor.

When you install the add-on, it triggers an installation handshake that generates the shared secret. That shared secret needs to be stored so you can create a unique JWT token for each API call.

How you create that JWT token for the API call will depend on what programming language you are using on your server. E.g. this is a toolkit provided by Atlassian for Node.js https://bitbucket.org/atlassian/atlassian-connect-express that has functions to deal with JWT so you don't need to write them from scratch.

This is all covered in the Atlassian Connect documentation https://developer.atlassian.com/static/connect/docs/latest/index.html

Rob Jackson March 10, 2017

Thank you, James. I think it's that initial step of creating an add-on that's been eluding us. I guess we were thinking we're not really building an add-on, just trying to read data out. 

We'll plug away with this extra clarity and see what progress we can make.

James Dellow
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 10, 2017

No problem. Confluence Cloud's security model does make it more difficult, but the upside is that its more secure smile

BTW you might like to join this mailing list https://groups.google.com/forum/#!forum/atlassian-connect-dev

0 votes
Rob Jackson March 8, 2017

Possibly related, but also no discernible answer: https://answers.atlassian.com/questions/11980450

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events