...
Jira trusts us. Now we need to print the token. Add '--print-tokens
' to to the last command:
Code Block |
---|
jirashell --server https://issues.redradishtech.com --consumer-key monitor-jira-license --key-cert rsa.pem --oauth-dance --print-tokens |
...
Code Block |
---|
Request tokens received. Request token: kLYKeT0g9EiJDDmqlxQTH9VjRs2fpFS6 Request token secret: snhWUlGQmzLu6I9ju1aQGNjulQQPT1lz Please visit this URL to authorize the OAuth request: https://issues.redradishtech.com/plugins/servlet/oauth/authorize?oauth_token=kLYKeT0g9EiJDDmqlxQTH9VjRs2fpFS6 Have you authorized this program to connect on your behalf to https://issues.redradishtech.com? (y/n) |
Hit 'n
' to abort.
Test your OAuth token
Now embed the 'Request token' and 'Request token secret' values you saw above into a new jirashell command:
...
You now have the three things you need for your script: the token, the token secret, and rsa.pub
private key.
Note that if your script is Python, you can use jirashell
as a library to handle all the ugly command-line parsing. In my case:
Code Block |
---|
$ cp venv/bin/jirashell check-jira-license
$ vim check-jira-license # Make changes
$ cat check-jira-license
#!/home/jturner/src/redradish/nagios-jira-license/venv/bin/python3
from jira.jirashell import *
options, basic_auth, oauth = get_config()
jira = JIRA(options=options, basic_auth=basic_auth, oauth=oauth)
print(jira.server_info()) |
This command can then be invoked using the same command-line flags as jirashell
:
Code Block |
---|
./check-license --server https://issues.redradishtech.com --access-token kLYKeT0g9EiJDDmqlxQTH9VjRs2fpFS6 --access-token-secret snhWUlGQmzLu6I9ju1aQGNjulQQPT1lz --key-cert rsa.pem |