jira python oauth: how to get the parameters for authentication?

前端 未结 3 404
野趣味
野趣味 2021-02-04 09:35

I am trying to use oauth to access jira, and I am reading this document: Welcome to jira-python\'s documentation.

But in this oauth part, I cannot figure out how I can g

3条回答
  •  伪装坚强ぢ
    2021-02-04 09:59

    I too am using jira-python. Since jira-python uses requests and requests-oauthlib I used those same libraries to implement the OAuth 1 dance necessary to get the tokens.

    First, setup JIRA:

    1. Generate RSA public/private key pair (you end up with rsa.pub and rsa.pem files). Your Python code will need access to the private key rsa.pem.
    2. Configure a JIRA application (done in JIRA admin under "Application Links") with "Incoming Authentication" and use the public key generated above. This is where you specify the consumer_key needed by jira-python

    Next, the OAuth dance. It's pretty simple with OAuth1Session from requests-oauthlib. Here is a simple example (CLI): JIRA Oauth in Python.

    The workflow is described in the requests-oauthlib docs: OAuth 1 Workflow.

    So, to summarize:

    • access_token - Obtained at the end of the OAuth 1 Workflow.
    • access_token_secret - Obtained at the end of the OAuth 1 Workflow.
    • consumer_key - Specified when you setup an "Application Link" in JIRA admin.
    • key_cert - The contents of the rsa.pem file (private key). The public key is also added when setting up the "Application Link" in JIRA admin.

提交回复
热议问题