【问题标题】:Unable to get access token from Workday's OAuth2 token endpoint无法从 Workday 的 OAuth2 令牌端点获取访问令牌
【发布时间】:2016-06-10 20:11:15
【问题描述】:

我正在尝试为 Workday 实施 OAuth 2 客户端,但我正在尝试请求令牌。我可以调用授权端点,它使用授权代码重定向到我的回调就好了,但是当我尝试将授权代码发布到令牌端点时,我得到:

"{\"error\" : \"application=service - invalid_request\"}"

我在 request_uri 上尝试了不同的 URL 编码组合。我试过传递一个状态参数。我什至已经代理了电话,以确保我实际上发送了正确的信息。这是我为尝试检索令牌而编写的 PHP 代码。

function callback() {
    $code = $_GET["code"];
    log_message('info', 'Using code: ' . $code);
    $url = "https://wd5-impl-services1.workday.com/ccx/oauth2/<redacted>/token";
    $data = array(
            'client_id' => '<redacted>',
            'client_secret' => '<redacted>',
            'grant_type' => 'authorization_code',
            'code' => $code,
            'redirect_uri' => 'https://<redacted>/account/callback'
    );

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_VERBOSE, 1);

    $result = curl_exec($curl);

    log_message('info', json_encode(curl_getinfo($curl)));

    curl_close($curl);

    log_message('info', json_encode($result));
    #redirect(base_url()."account/login");
}

我有点不知道出了什么问题。我梳理了所有论坛,并尝试与有关其他 OAuth 2 服务器的对话进行比较,但我找不到任何关于我的具体问题的信息。有其他人使用 Workday 成功完成此任务吗?

【问题讨论】:

  • 我知道这个问题很老了,但是您是否在 Workday 中设置了 API 客户端?

标签: oauth2 workday-api


【解决方案1】:

试试这个...
它对我有用:

curl -X POST \
  https://wd2-impl-services1.workday.com/ccx/oauth2/ <tenant> /token \
  -H 'Authorization: Basic T0RJM1pqa3pZbVV0WXpBeU15MDBZV0kwTFRnMU4yRXROV1UyTW1Wak16ZzFNamxqOmNudzZwbDI3Zmc4eG54YWIxamE1cWR6cHlqMGtkZW9mdmNubjF0czhyN3U2OHpiZ3llOTJyajZvbWhiMjY3ZjlrYzE0ajU3d3F5cHQyNjN5Ymc3N3h3ZXdvc3h2bmVodTc1Mw==' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Host: wd2-impl-services1.workday.com' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 60' \
  -d 'grant_type=authorization_code&code=4pwzdn1vs63alnm1fyas62za6'

它的结果是:

{
    "refresh_token": "r50ditl18yt0osdfnoasdsadfouwerljsdfkauooiu5h5hvanlkf8ow5n9ugjc3d8wiz99c6xxbi2t8ruqhxhohfzl4jfmuy",
    "token_type": "Bearer",
    "access_token": "e1zrm1ccwb9werwer6upb3tkp"
}

【讨论】:

    猜你喜欢
    • 2015-02-11
    • 2021-10-10
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 2021-11-10
    • 2013-03-25
    • 2020-10-08
    相关资源
    最近更新 更多