jira python oauth:如何获取用于身份验证的参数? [英] jira python oauth: how to get the parameters for authentication?
问题描述
我正在尝试使用oauth访问jira,并且正在阅读此文档:欢迎使用jira-python的文档.
I am trying to use oauth to access jira, and I am reading this document: Welcome to jira-python's documentation.
但是在此oauth部分中,我无法弄清楚如何获取这些参数:
But in this oauth part, I cannot figure out how I can get these parameters:
access_token, access_token_secret, consumer_key, key_cert
推荐答案
我也正在使用jira-python.由于jira-python使用请求和
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.
首先,设置JIRA:
- 生成RSA公钥/私钥对(最终得到
rsa.pub
和rsa.pem
文件).您的Python代码将需要访问私钥rsa.pem
. - 使用传入身份验证"配置JIRA应用程序(在JIRA管理员的应用程序链接"下完成),并使用上面生成的公共密钥.在这里指定jira-python 所需的
consumer_key
- Generate RSA public/private key pair (you end up with
rsa.pub
andrsa.pem
files). Your Python code will need access to the private keyrsa.pem
. - 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
接下来,是OAuth舞蹈.使用 requests-oauthlib 中的OAuth1Session
非常简单.这是一个简单的示例(CLI): Python中的JIRA Oauth .
Next, the OAuth dance. It's pretty simple with OAuth1Session
from requests-oauthlib. Here is a simple example (CLI): JIRA Oauth in Python.
requests-oauthlib 文档中描述了工作流程:<一个href ="http://requests-oauthlib.readthedocs.org/en/latest/oauth1_workflow.html" rel ="noreferrer"> OAuth 1工作流.
The workflow is described in the requests-oauthlib docs: OAuth 1 Workflow.
因此,总结一下:
- access_token-在OAuth 1工作流程结束时获得.
- access_token_secret-在OAuth 1工作流程结束时获得.
- consumer_key-在JIRA管理员中设置应用程序链接"时指定.
- key_cert-
rsa.pem
文件的内容(私钥).在JIRA管理员中设置应用程序链接"时,还会添加公共密钥.
- 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.
这篇关于jira python oauth:如何获取用于身份验证的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!