Skip to content

Instantly share code, notes, and snippets.

@mrueegg
Created March 9, 2017 17:10
Show Gist options
  • Save mrueegg/6050a3f79601b8fc52b96b7cfcd5447f to your computer and use it in GitHub Desktop.
Save mrueegg/6050a3f79601b8fc52b96b7cfcd5447f to your computer and use it in GitHub Desktop.
Create an OAuth request token with Python
from oauthlib.oauth1 import SIGNATURE_RSA
from requests_oauthlib import OAuth1Session
import json
import webbrowser
request_token_url = 'http://localhost:6990/bamboo/plugins/servlet/oauth/request-token'
oauth = OAuth1Session(your_consumer_key_from_above,
signature_type='auth_header',
signature_method=SIGNATURE_RSA,
rsa_key=your_RSA_key_from_above)
request_token = oauth.fetch_request_token(request_token_url)
Next, we have to get the authorization of the user:
authorize_url = 'http://localhost:6990/bamboo/plugins/servlet/oauth/authorize'
auth_link = '{}?oauth_token={}'.format(authorize_url, request_token['oauth_token']))
webbrowser.open(auth_link)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment