I am going testing to see if a project idea is feasible and can be supported using JIRA.
I want to do a pretty simple rest API call like the ones listed here:
https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis
However, since using a service account eats a license, I am trying to get oauth tokens to work.
I followed a couple of KBs and got the PHP example working:
https://bitbucket.org/atlassianlabs/atlassian-oauth-examples/src/master/php/
I am able to successfully generate:
oauth_token XXXXXXXXXXXXXXXXXXXXXXXX
oauth_token_secret XXXXXXXXXXXXXXXXXXXXXXX
oauth_expires_in 157680000
oauth_session_handle XXXXXXXXXXXXX
oauth_authorization_expires_in 160272000
Which is pretty neat in itself!
Now all the "Examples" are using a java client from Atlassian, so I am a bit confused on what's next. From my use of tokens in the past, I could simply supply these in the POST header. But I cannot seem to find any documentation on that. Is this not the case?
I see a few github projects that help with this and PHP, but there is little documentation and dont seem really supported. Was hoping to get some further guidance. Thanks!
After doing more digging, it seems the oauth and rest API relationship is more complicated than simply getting a token and passing this through a post call.
The example, listed above does call the API and this can be used as a start.
Specifically, the example uses this section in the index.php
$priorities = $app['oauth']->getClient(
$oauth['oauth_token'],
$oauth['oauth_token_secret']
)->get('rest/api/2/priorities')->send()->json();
This can of course be modified and changed to your needs. The example seems to be more complex than it needs to be. TWIG is an easy way to display variable items in HTML that were generated in PHP, however to someone like me who is not use to it, it takes a little longer to parse.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.