admin管理员组文章数量:1295625
Further to my post Xero api connection
I've created a very simple test code based on / The code opens to the xero permissions page correctly but when it returns (with a url containing all necessary parts) I just get an error response of "invalid_client" from the api.
The client id is correct code and url string being returned so I'm not sure why it's not validating and returning my tokens ??
My Code:
<?php
session_start();
$clientId='BFFD3*************B848C70';
$redirectUri='http://localhost/starter/beta.php';
$state = 'abc1';
$codeVerifier = 'RgdEXOZqF4lUQ8KcYJps7eY0zd3OsPQQOwVDdl86e3';
// callback from xero
if($_GET['code'] && $state == $_GET['state']){
$session_state = $_GET['session_state'];
$state = $_GET['state'];
$code = $_GET['code'];
$scope = $_GET['scope'];
// Token endpoint URL
$tokenUrl = '';
// cURL options
$ch = curl_init($tokenUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'grant_type' => 'authorization_code',
'client_id' => $clientId,
'code' => $code,
'redirect_uri'=>$redirectUri,
'code_verifier' =>$codeVerifier
]));
// Execute the request
$response = curl_exec($ch);
if(curl_error($ch)) {
var_dump(curl_error($ch));
}
curl_close($ch);
print_r($response);
exit();
} else {
// initial auth
// opens page to authorise permission
// workign as expected
$codeChallenge = base64url_encode(hash('sha256', $codeVerifier, true));
$url = ";client_id=$clientId&redirect_uri=$redirectUri&scope=openid profile email accounting.transactions&state=$state&code_challenge=$codeChallenge&code_challenge_method=S256";
header("Location:$url");
exit();
}
本文标签: phpXero API PKCE giving Invalidclient errorStack Overflow
版权声明:本文标题:php - Xero API PKCE giving Invalid_client error - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741623196a2388932.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论