Python 用jirarestapiv3测试我的JWT令牌,它返回一个“;requests.exceptions.HTTPError:404客户端错误:找不到url:”;
我正在开发一个Atlassian connect插件。在这里,我在测试我的JWT令牌以获得RESTAPI v3的问题时遇到了一个问题。我正在使用FLASK、atlassian jwt的python库,下面是我的代码 我不熟悉flask、python和Atlassian应用程序开发。所以请不要介意我的noob技能:出汗和微笑:Python 用jirarestapiv3测试我的JWT令牌,它返回一个“;requests.exceptions.HTTPError:404客户端错误:找不到url:”;,python,flask,jwt,jira-rest-api,atlassian-connect,Python,Flask,Jwt,Jira Rest Api,Atlassian Connect,我正在开发一个Atlassian connect插件。在这里,我在测试我的JWT令牌以获得RESTAPI v3的问题时遇到了一个问题。我正在使用FLASK、atlassian jwt的python库,下面是我的代码 我不熟悉flask、python和Atlassian应用程序开发。所以请不要介意我的noob技能:出汗和微笑: import atlassian_jwt import requests from flask import Flask, request, jsonify, redire
import atlassian_jwt
import requests
from flask import Flask, request, jsonify, redirect, render_template
ADDON_KEY = "ADDON_KEY "
clients = {}
if __name__ == '__main__':
app = Flask(__name__)
# App descriptor
descriptor = {
"modules": {},
"name": "my connect app",
"description": "Atlassian Connect app",
"key": "my connect app-V1",
"baseUrl": "ngrok url",
"vendor": {
"name": "Example, Inc.",
"url": "http://example.com"
},
"lifecycle": {
"installed": "/register",
},
"authentication": {
"type": "jwt"
},
"apiVersion": 1,
"modules": {
"generalPages": [
{
"url": "/what.html",
"key": "hello-world",
"location": "system.top.navigation.bar",
"name": {
"value": "Index page"
}
}
]
},
"scopes": [
"read",
"write"
]
}
class SimpleAuthenticator(atlassian_jwt.Authenticator):
def get_shared_secret(self, client_key):
return clients[client_key]['sharedSecret']
auth = SimpleAuthenticator()
@app.route('/', methods=['GET'])
def redirect_to_descriptor():
return redirect('/descriptor')
@app.route('/descriptor', methods=['GET'])
def get_descriptor():
print("descriptor triggered: \n",
jsonify(descriptor))
return jsonify(descriptor)
@app.route('/register', methods=['POST'])
def register():
print("route triggered")
global clients
client = request.get_json()
# clients[client['clientKey']] = client
clients['clientKey'] = client['clientKey']
clients['sharedSecret'] = client['sharedSecret']
clients['baseUrl'] = client['baseUrl']
print(clients['baseUrl'], " : ", client['baseUrl'])
return ' ', 204
@app.route('/what.html', methods=['GET','POST'])
def main_page():
print("\n What method triggeted")
return render_template('ind.html')
@app.route('/ping', methods=['GET','POST'])
def ping():
print("Ping method triggered")
print("\n ", clients, "\n")
ping_url =' /rest/api/3/issue/issue_id'
jwt_authorization = atlassian_jwt.encode_token('GET', ping_url ,clientKey =
clients['clientKey'],sharedSecret= clients['sharedSecret'])
print("\n JWT KEY: ", jwt_authorization,"\n")
result = requests.get(clients['baseUrl'].rstrip('/') + ping_url, headers={'Authorization':
jwt_authorization})
result.raise_for_status()
print(result.status_code, result.json())
print("end Ping method")
return ' ', 204
app.run(host='127.0.0.1',port=8000,debug=True)
虽然这段代码返回404客户端错误,但我还有几个其他问题
1.a而不是这个
Error: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://mydomain.atlassian.net/jira/rest/api/latest/issue/issue_id