【问题标题】:OKTA - not able to retrieve authorization codeOKTA - 无法检索授权码
【发布时间】:2020-07-06 04:54:09
【问题描述】:

我正在尝试使用以下端点从重定向 URI 获取授权代码,但我得到的只是一个 HTML 页面作为响应的一部分。我需要从 api 响应中获取授权码。当我使用 Postman 时,我可以看到以下值作为响应标头位置的一部分。

https://oidcdebugger.com/debug/?code=H9QD-knUSRO-xqXI4AQA&state=IL'

但我不确定如何从我的代码中获取上述值。下面是我的代码sn-p,有人可以帮我吗。

Const options = {
    followRedirect: true,
    method: 'GET',
    uri: 'https://dev-XXXXX.okta.com/oauth2/default/v1/authorize',
    qs: {
        client_id:'XXXXXXXXXXXXXXXX', 
        "response_type":'code',
        scope:"openid",
        sessionToken:"20111nGGrl17go5apfKtY-nwcFSemP1VdMJaqT5ceGQpbOIhJ1eq9US",
        "redirect_uri":"https://oidcdebugger.com/debug",
        "state":"IL",
        nonce:"XXX"
          },
    headers: {
        'Accept':"application/json" ,
        'Content-Type': "application/json"
             }
  }

request(options)
  .then(function (response) {
    console.log("**********************response***************************************");   
   console.log(response);
  })
  .catch(function (err) {
    console.log("**********************error***************************************");   
    //console.log(err.options);
    console.log(err.response.req.path);
  });

【问题讨论】:

  • 这里有什么问题?我们可能需要看一些代码吗?大概。也许看看how to ask the perfect question,看看你是否可以改进你的,让我们更容易回答? :-)

标签: oauth oauth-2.0 google-oauth okta okta-api


【解决方案1】:

https://dev-XXXXX.okta.com/oauth2/default/v1/authorize”是前端 REDIRECT 调用。端点会将您重定向到您的重定向网址“https://oidcdebugger.com/debug”,因此这是预期的。您需要提供一个回调函数/端点作为您的重定向 URL,因此当上述端点调用回调函数时将具有代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    • 2020-06-12
    • 2021-04-12
    • 1970-01-01
    • 2019-10-23
    • 2022-08-04
    相关资源
    最近更新 更多