승인 코드를 사용하여 액세스 토큰을 얻으려고하거나 토큰을 새로 고칩니다. 다음 코드를 사용하고 있지만이 오류는 invalid Auth code
입니다. 클라이언트 ID 및 비밀 ID에 샌드 박스 자격 증명을 사용하고 있습니다.페이팔에 잘못된 인증 코드 오류가 발생했습니다.
iOS 디바이스에서 $PaypalToken
을받습니다.
그래서 문제가 무엇입니까?
이 원래 페이팔 요청입니다 : 내가 $postdata = 'grant_type=client_credentials';
다음은 follwing을 반환 변경하는 경우
curl ' https://api.paypal.com/v1/oauth2/token ' \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Authorization: Basic QWZV...==" \
-d 'grant_type=authorization_code&response_type=token& redirect_uri=urn:ietf:wg:oauth:2.0:oob&code=EBYhRW3ncivudQn8UopLp4A28...'
PHP Code:
$host2 = 'https://api.sandbox.paypal.com/v1/oauth2/token';
$clientId = 'XXXXXXX';
$clientSecret = 'xxxxxx';
$PaypalToken = $values->Token;
$postdata = 'grant_type=authorization_code&response_type=token&redirect_uri=urn:ietf:wg:oauth:2.0:oob&code='.$PaypalToken;
//$postdata = 'grant_type=client_credentials&response_type=token&code=wwwwwwwwwwwww';
//$postdata = 'grant_type=client_credentials';
$curl = curl_init($host2);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_USERPWD, $clientId.":".$clientSecret);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
# curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
$response = curl_exec($curl);
// Convert the result from JSON format to a PHP array
$json_response = json_decode($response,true);
if (empty($response)) {
curl_close($curl); // close cURL handler
$returnArr['Success'] = 0;
$returnArr['Message'] = $json_response['error_description'];
echo json_encode($returnArr);exit;
} else {
$info = curl_getinfo($curl);
//echo "<pre>";print_r($info);print_r($response);
curl_close($curl);
if($info['http_code'] != 200 && $info['http_code'] != 201) {
$returnArr['Success'] = 0;
$returnArr['Message'] = $json_response['error_description'];
echo json_encode($returnArr);exit;
}
}
echo "<pre>";print_r($json_response);
:
가 어떻게 aceeess 토큰을 얻기 위해, 새로 고침 토큰? 미리 감사드립니다.Array ( [scope] => openid https://uri.paypal.com/services/invoicing https://api.paypal.com/v1/payments/ .* https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/vault/credit-card/ .*
[access_token] => A015KRoybqmm6eJqEzxX65jtGsd-L96g20KsAugrvSkB
[token_type] => Bearer
[app_id] => APP-80W284485P519543T
[expires_in] => 28800
)
답변 해 주셔서 감사합니다. 그것은 쓸모있다. – DS9