Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

First, you need to configure an application link.

Go in JIRA Applications administration, then select Application LinksRendez-vous dans l'administration de Confluence (General Configuration) et cliquez sur Application Links dans le menu de gauche. Sur l'écran listant les appLinks, entrez l'url de l'application devant se connecter au plugin et cliquez sur Create New Link. Si votre application n'a pas d'url, entrez une url qui ne répondra pas, peu importe pour la suite.

Image Removed

Lorsque vous cliquez sur le bouton de création, Confluence risque (dans certains cas) d'afficher une fenêtre indiquant que l'application ne répond pas, comme ci-dessous. Ce n'est pas important, cliquez sur Continue.

Image Removed

Confluence vous demande ensuite les informations de paramétrage de la connexion OAuth, comme dans l'écran ci-dessous :

Image Removed

Entrez les informations suivantes :

...

Links. Enter your application URL (the one going to call the REST API), then click Create New Link. If your application does not have an URL, enter any non existing URL, it's not important (unless you really want the full OAuth mechanism, with callbacks).

Image Added

Sometimes, or if your application does not have any URL, you'll see this window, complaining that the application does not answer. Just click Continue.

Image Added

You'll then be asked for OAuth configuration data, as shown below :

Image Added

Enter the following information :

  • Application Name : Enter a name for your application
  • Application Type : Must be Generic Application, and should be pre-filled.
  • Service Provider Name : This is JIRA (or more precisely Ovyka Satisfaction for JIRA).
  • Consumer key : the key identifying the OAuth consumer (the same that you configured in your application). Here I'm using a key which is hardcoded in the REST client I'm using harcoded-consumer.
  • Shared secret : la clef partagée (ou clef publique) associée au consumer entré au dessusthe public shared key associated with the consumer key.
  • Request Token URL : CONLFUENCEJIRA_BASE_URL + "/plugins/servlet/oauth/request-token"
  • Access Token URL :  CONLFUENCEJIRA_BASE_URL URL + "/plugins/servlet/oauth/access-token"
  • Authorize URL :  CONLFUENCEJIRA_BASE_URL URL + "/plugins/servlet/oauth/authorize"

Pour exemple, l'url de base (CONFLUENCEFor the example, the base url (JIRA_BASE_URL) de l'instance Confluence utilisée ici est is http://localhost:19902990/confluence. Par conséquent, la jira. So, for example, the Request Token URL est donc is :   http://localhost:19902990/confluencejira/plugins/servlet/oauth/request-token.

Cliquez ensuite sur Continue. Confluence vous demande les détails du consumer (la consumer key et le public key (shared secret) ont déjà été entrées à l'étape précédente, mais il faut les entrer de nouveau ici...

Image Removed

Cliquez sur Continue. Confluence configure le lien, et il doit apparaître ensuite dans la liste des AppLinks configurés, comme ci-dessous :

Image Removed

La configuration de l'AppLink dans Confluence est terminée. Vous pouvez commencer à utiliser le plugin depuis votre application, en utilisant le protocole d'autorisation OAuth. Dans le paragraphe suivant, une démonstration est présentée en utilisant un client simple en ligne de commande.

Appel du plugin via un client OAuth

La démonstration qui suit utilise un client en ligne de commande. Certaines manipulations ne sont pas nécessaires avec une application plus évoluée qui sait gérer le protocole OAuth seul.

D'abord, j'utilise mon client pour demander à Confluence un RequestToken.

Info

Notez que dans la commande que j'utilise ci-dessous, je ne fournis pas d'url de callback (qui devrait être à la fin de la ligne de commande, après l'url de base de Confluence). Dans mon cas, si je ne fournis pas cette url, Confluence affichera le code de vérification (voir plus bas) dans le navigateur. Si vous fournissez cette url, il sera envoyé à votre application via cette url de callbak.

...

themeDJango

...

Then click on Continue. JIRA will ask you again the consumer details (consumer key and public shared key), you have to enter them again.

Image Added

Click on Continue. Cliquez sur Continue. JIRA will configure the link, and it will appear in your list of application links, as shown below. JIRA Application link configuration is done now. You can start using the REST API using OAuth authorization.

Image Added

In next section, I'll demonstrate an example, of authorization setup and REST API usage.

Oauth authorization setup and usage

Here I'm using the REST client mentionned above. Some commands are not mandatory when using a more advanced application that knows how to handle OAuth protocol.

First, I'm asking for a RequestToken.

 

Info

Note here that I do not provide a callback URL. This url would be called by OAuth processor, to continue OAuth protocol conversation. I'm doing everything by hand here, on the command line. If you provide this url, the verification we'll get below will be sent back to our application automatically.

Code Block
themeDJango
$ java -jar rest-oauth-client-1.0.one-jar.jar requestToken http://localhost:19902990/confluencejira
Token is MdJ8Zqsokinlsr3XgGGufBRHsrKYf3JHmnVb4mCmjWO9PBmeN5jYXvb6g3q8w2bw
Token secret is 8bH6kMgIuTHFqIu1ZR6DbkKUMBB287jcInO6HnmbWGbhJCDr5aWvmpT2r0OTrlfz
Retrieved request token. go to http://localhost:19902990/confluencejira/plugins/servlet/oauth/authorize?oauth_token=MdJ8Zqsokinlsr3XgGGufBRHsrKYf3JH 

Confluence me répond en me fournissant une url que je dois ouvrir pour autoriser l'accès de mon client dans Confluence. L'écran présenté lors de l'ouverture de l'url est le suivant :

Image Removed

Confluence me demande d'autoriser l'accès et m'indique que les accès effectués via le token OAuth qui sera généré le seront en mon nom (admin). L'utilisateur utilisé est celui qui est connecté à Confluence lors de l'accès à l'url fournie. Si vous n'êtes pas connecté, Confluence vous demandera d'abord de vous connecter avant d'afficher l'écran d'autorisation OAuth.

Je clique sur Allow, et  Confluence m'affiche un écran contenant le code de vérification :

Image Removed

...

mnVb4mCmjWO9PBmeN5jYXvb6g3q8w2bw

JIRA answers with :

  • a request token,
  • a request token secrect code,
  • an url to open to authorize OAuth.

Here is what is shown when accessing the url :

Image Added

JIRA asks me to authorize the access and indicates that the calls made using this allowed OAuth token will be made using the credentials of the user who opens the authorization url (admin here). If you want a specific user to be used for API calls, make sure to use this user to access this authorization url.

I click on  Allow, and JIRA provides me the verification code (the one that would be sent to your application directly if you provide a callback url).

Image Added

I can then request for an AccessToken, that I will be using to make calls to the plugin REST API.

Code Block
themeDJango
zeus:rest-oauth phoenix$$ java -jar rest-oauth-client-1.0.one-jar.jar accessToken http://localhost:19902990/confluencejira MdJ8Zqsokinlsr3XgGGufBRHsrKYf3JHmnVb4mCmjWO9PBmeN5jYXvb6g3q8w2bw 8bH6kMgIuTHFqIu1ZR6DbkKUMBB287jcInO6HnmbWGbhJCDr5aWvmpT2r0OTrlfz k621j4rbi2v9
Access token is : oSsNuFfMwL3MDDxYZQ1J1DeU05LDPRiV

Ici j'ai fourni, dans l'ordre, le RequestToken et le Token Secret fournis lors de mon premier appel ci dessus, suivis du code de vérification fourni par confluence après l'autorisation de l'accès. Confluence me répond en me fournissant l'AccessToken.

Je peux ensuite appeler le plugin directement depuis mon client, sans fournir de login/password :

Code Block
themeDJango
zeus:rest-oauth phoenix$ java -jar rest-oauth-client-1.0.one-jar.jar request oSsNuFfMwL3MDDxYZQ1J1DeU05LDPRiV http://localhost:1990/confluence/rest/docfinder/1.0/find/key/AAA123457
RESPONSE IS {"key":"AAA123457","status":401,"message":"One document found.","results":["http://localhost:1990/confluence/download/attachments/983044/gefco-atlas.csr?version=1&modificationDate=1445446105491&api=v2"]}

...

lZNpyhPR6YmpQ3b0iM69bhcMVpjM3K3e

I gave here, ordered :

  • RequestToken (from first call above)
  • Token Secret (from first call above)
  • the verification code given by Jira.

JIRA then provides the AccessToken.

I can then call the plugin REST API :

Code Block
themeDJango
$ java -jar rest-oauth-client-1.0.one-jar.jar request lZNpyhPR6YmpQ3b0iM69bhcMVpjM3K3e http://localhost:2990/jira/rest/satisfaction/1.0/project/evaluations/all/10000

RESPONSE IS[{"satisfaction":{"projectId":10000,"issueId":10000,"reporterId":"tstark","answers":[{"fieldId":1,"fieldName":"Overall answer satisfaction","intAnswer":4,"fieldType":"EVALUATION","overall":true},{"fieldId":2,"fieldName":"Time to answer satisfaction","intAnswer":2,"fieldType":"EVALUATION","overall":false},{"fieldId":3,"fieldName":"Agent satisfaction","intAnswer":4,"fieldType":"EVALUATION","overall":false}],"date":1491895646549,"issueDate":1491842255195},"issueTypeIconUrl":"/images/icons/issuetypes/story.svg","userName":"Anthony Stark","userAvatarlUrl":"http://www.gravatar.com/avatar/6c2823e1531be820e8c2a4d719e1d38f?d=mm&s=16","userProfileUri":"/secure/ViewProfile.jspa?name=tstark","issue":{"created":true,"subTask":false,"editable":true},"displayDate":"11/Apr/17 9:27 AM","iso8601DisplayDate":"2017-04-11T09:27:26+0200","creationDisplayDate":"10/Apr/17 6:37 PM","iso8601CreationDisplayDate":"2017-04-10T18:37:35+0200","overallScore":4,"issueDisplay":{"baseUrl":"/jira","iconUrl":"/images/icons/issuetypes/story.svg","key":"TP-1"},"userDisplay":{"id":0,"baseUrl":"/jira","avatarUrl":"http://www.gravatar.com/avatar/6c2823e1531be820e8c2a4d719e1d38f?d=mm&s=16","profileUrl":"/secure/ViewProfile.jspa?name=tstark","name":"Anthony Stark"},"agentDisplay":{"id":0,"baseUrl":"/jira","avatarUrl":"http://www.gravatar.com/avatar/64e1b8d34f425d19e1ee2ea7236d3028?d=mm&s=16","profileUrl":"/secure/ViewProfile.jspa?name=admin","name":"admin"},"field1":{"name":"Overall answer satisfaction","fieldId":1,"issueId":10000,"value":"4","rating":true},"field2":{"name":"Time to answer satisfaction","fieldId":2,"issueId":10000,"value":"2","rating":true},"field3":{"name":"Agent satisfaction","fieldId":3,"issueId":10000,"value":"4","rating":true}}]

If you don't provide the authentication, you'll receive an empty response :

Code Block
themeDJango
zeus:rest-oauth phoenix$ $ curl  -X GET "http://localhost:19902990/confluencejira/rest/docfindersatisfaction/1.0/project/findevaluations/keyall/AAA123457"
{"status":201,"message":"User was not found."}10000
RESPONSE IS[]

Contact

Should you have any questions about Ovyka Satisfaction for JIRA plugin, or should you encounter any problem using it, feel free to contact us by dropping an email to this address : contact@ovyka.com

...