【问题标题】:How to use pass access token for using Rest Api in Jira Server after generating oauth access token. Using Nodejs(request library)生成 oauth 访问令牌后如何使用 pass 访问令牌在 Jira Server 中使用 Rest Api。使用 Nodejs(请求库)
【发布时间】:2020-04-02 07:27:39
【问题描述】:
request.get('http://localhost:8080/rest/api/2/project',
    {
        oauth:{
            consumer_key:consumer_key,
            consumer_secret:consumer_secret,
            oauth_signature_method: RSA-SHA1,
            token: oauth_access_token,
            token_secret: oauth_access_token_secret
        },
        qs:{user_id:user_id} // or screen_name
    },
    function (err, res, body) {
        console.log(err)
        console.log(body)
    }
)

【问题讨论】:

    标签: node.js oauth request jira jira-rest-api


    【解决方案1】:

    oauth 访问令牌可以通过以下方式在发出的 get 请求中传递

    
    request.get('http://localhost:8080/rest/api/2/project', {
      'auth': {
        'bearer': oauth_access_token
      },
     'qs':{user_id:user_id} // or screen_name
    }, function (error, response, body) {
       // Do more stuff with 'body' here
    })
    

    【讨论】:

    • 我在正文中得到了空数组 ([ ])。即使我在 jira 中有项目
    • 你还能记录其他参数吗.. console.log(error, response, body);函数内部
    • 另外,请确保服务器在 jira 项目的 8080 端口上运行
    • JIra 在 8080 上运行,我记录了所有 3 个。我得到了错误:null body: [] 并且响应我得到了整个 resp 对象的 body: []
    • 调试 jira 服务器并将日志放入 /rest/api/2/project 端点以检查那里正在发生什么处理......也许您的 user_id 相关数据处理返回 [] 空结果。跨度>
    猜你喜欢
    • 2012-03-23
    • 2023-02-02
    • 2020-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-28
    • 2021-11-27
    相关资源
    最近更新 更多