Reactjs 反应+;Atlassian Jira云Api+;Cors Anywhere:通过POST添加工作日志返回403

Reactjs 反应+;Atlassian Jira云Api+;Cors Anywhere:通过POST添加工作日志返回403,reactjs,jira-rest-api,cors-anywhere,Reactjs,Jira Rest Api,Cors Anywhere,这件事已经纠缠了好几天了。我正在React中制作一个应用程序,使用Atlassian的Jira Cloud Rest API,我想从我的应用程序中记录Jira问题的工作。然而,每次我尝试,我得到一个403。Postman works中的相同请求创建了worklog,这很奇怪。我设置了一个证书并使用cors anywhere,以便能够在我的React应用程序中使用HTTPS,但在其他方面,查询是相同的 我在Atlassian论坛上读到了很多关于人们在需要发布Atlassian API时不确定该做什

这件事已经纠缠了好几天了。我正在React中制作一个应用程序,使用Atlassian的Jira Cloud Rest API,我想从我的应用程序中记录Jira问题的工作。然而,每次我尝试,我得到一个403。Postman works中的相同请求创建了worklog,这很奇怪。我设置了一个证书并使用cors anywhere,以便能够在我的React应用程序中使用HTTPS,但在其他方面,查询是相同的

我在Atlassian论坛上读到了很多关于人们在需要发布Atlassian API时不确定该做什么的文章。这是一个无法修复的奇怪问题,还是我缺少了一个相关的标题

下面是我在React应用程序的ComponentDidMount()中进行的获取调用。是我用于CORS anywhere/纱线的代理

fetch("https://localhost:8080/my-domain.atlassian.net/rest/api/2/issue/ISSUE-1/worklog,{
            headers: {
              "Access-Control-Allow-Origin": "https://localhost:3000/",
              "X-Atlassian-Token": "no-check",
              "Content-Type": "application/json;charset=UTF-8",
              "Authorization": "Basic base64token",

            },
            method: "POST",
            responseType: 'json',
            body: {
                 "timeSpent":"2h 48m",
                 "author":{
                      "accountId":"123456789",      
                      "active":true,
                      "avatarUrls":{
                             "16x16":"https://avatar-cdn.atlassian.com/...",
                             "24x24":"https://avatar-cdn.atlassian.com/...",
                             "32x32":"https://avatar-cdn.atlassian.com/...",
                             "48x48":"https://avatar-cdn.atlassian.com/..."
                      },
                      "displayName":"User Name", 
                      "emailAddress":"user.name@gmail.com",
                      "key":"user.name",
                      "name":"user.name",
                      "self":"https://my-domain.atlassian.net/rest/api/2/user?username=user.name",
                      "timeZone":"Europe/Stockholm"
                  },
                  "comment":"bla bla bla",
                  "started":"2018-07-19T21:32:18.843+0200"
             }
        })
        .then((res) => res.json())
        .then(function(resJson){ 
            console.log(resJson
        })
这是我运行的server.js

const path = require('path')
const fs = require('fs')
const express = require('express')
const https = require('https')

const app = express();
const host = process.env.HOST || '0.0.0.0';
const port = process.env.PORT || 8080;

const cors_proxy = require('cors-anywhere');
cors_proxy.createServer({
    httpsOptions: {
        key: fs.readFileSync(path.resolve('server.key')),
        cert: fs.readFileSync(path.resolve('server.crt'))
    },
    originWhitelist: ['https://localhost:3000', 'https://localhost:8080'], 
    requireHeader: ['origin', 'x-requested-with'],
    removeHeaders: ['cookie', 'cookie2']
}).listen(port, host, function() {
    console.log('Running CORS Anywhere on ' + host + ':' + port);
});

<> P>而不是使用基本的Auth-你应该考虑建立。您可以从开始使用,它将处理附加组件的安装和JWT令牌的验证。基本上,您将能够从服务器(使用JWT令牌签名)执行安全调用,或者从前端(嵌入Jira内部)执行对Jira API的调用,这些调用将作为特定用户执行,这将生成正确的“更新者”条目。

有趣!即使拥有Atlassian托管的Jira云实例(即Jira未托管在我拥有的服务器上),您是否可以构建Atlassian Connect附加组件?是的,绝对可以。实际上,您只能为Jira Cloud构建atlassian connect附加组件。Atlassian Connect framework仅适用于Atlassian云产品。