SAP CPI - PHP Curl 获取令牌

问题描述 投票:0回答:1

我尝试从 SAPI CPI 获取令牌,但收到 401 - 返回的错误凭据。这是我的代码:-

$client_id="***";
$client_secret="***";
              
// Define the POST request to retrieve the token
$post_data = array(
    "grant_type" => "client_credentials",
    "client_id" => $client_id,
    "client_secret" => $client_secret
);              

$url='https://***.authentication.us10.hana.ondemand.com/oauth/token';

//open connection
$ch = curl_init();

$content_type = array('Content-Type: application/x-www-form-urlencoded');

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $content_type); 

//execute post
$result = curl_exec($ch);

我已经设法使用具有相同客户端 ID 和密码的 POSTMAN 来实现此工作。非常感谢任何帮助。

谢谢

马丁

curl token
1个回答
0
投票

有这方面的最新消息吗?我需要做同样的事情。 谢谢你

© www.soinside.com 2019 - 2024. All rights reserved.