Paypal "Log in with" integration redirect
I am integrating Login with paypal on my site but I've always the error message :
Relying Party Validation error: redirect_uri provided in the request does not match with the registered redirect_uri. Please check the request.
and I think that I did everything right, I've used this example : http://www.sitepoint.com/implement-user-log-paypal/ and also "www.formget.com/paypal-oauth/"
index.php
<script src="https://www.paypalobjects.com/js/external/api.js"></script>
<script>
paypal.use( ["login"], function(login) {
login.render ({
"appid": "MY_APP_ID",
//"authend": "sandbox",
"scopes": "profile email https://uri.paypal.com/services/paypalattributes",
"containerid": "myContainer",
"locale": "en-us",
"returnurl": "<?php echo('http://'.$_SERVER['HTTP_HOST'].preg_replace('/index.php/','result.php',$_SERVER['SCRIPT_NAME']))?>"
});
});
</script>
result.php
<?php require('paypal_login_inc.php') ?>
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<title>Login with PayPal - Demo App</title>
<style type="text/css">
body {
text-align: center;
padding:20px;
}
</style>
</head>
<body>
<h1>Login with PayPal - Demo App</h1>
<p>Great! Now you are a member of our site.</p>
<hr/>
<h2>Your Data</h2>
<p><b>Name:</b> <?php echo htmlspecialchars_decode($user->given_name . ' ' . $user->family_name); ?></p>
<p><b>Address:</b> <?php echo htmlspecialchars_decode($user->address->street_address . ', ' . $user->address->locality); ?></p>
<hr/>
<p><button class="btn btn-success form-control" type="button" onclick="window.close()">Ok, done.</button></p>
</body>
</html>
paypal_login_inc.php
<?php
include('./httpful.phar');
// helper package autoload.
require __DIR__ . '/PayPal-PHP-SDK/autoload.php';
// setting some variables here.
$clientId = 'MY_APP_ID';
$clientSecret = 'MY_SECRET_ID';
$requestData = '?grant_type=authorization_code&code='.$_GET['code'].'&return_url=http://MY_RETURN_URL/result.php';
// here we exchange the authorization code with access and refresh tokens. api.sandbox
$response = HttpfulRequest::get('https://api.paypal.com/v1/identity/openidconnect/tokenservice' . $requestData)
->authenticateWith($clientId, $clientSecret)
->send();
$jsonResponse = json_decode($response->raw_body);
// checking out for errors.
if(isset($jsonResponse->error))
{
die('Error: just got some problems during operations. Try again.');
}
// getting user data, using the Identity APIs. api.sandbox
$response = HttpfulRequest::get('https://api.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid')
->contentType("application/json")
->authorization($jsonResponse->access_token)
->authenticateWith($clientId, $clientSecret)
->send();
// user data is here!
$user = json_decode($response->raw_body);
?>
I've configured the same return url in index.php and paypal_login_inc.php, I have also configured the return url in the paypal application :
I have also set the same url for sandbox and live application and also create a new app like in this site : https://medium.com/@bartriepe/log-in-with-paypal-a-fractal-of-bad-design-58ce19939a9d
So where is the problem ? is it a paypal bug ?
thank you for your help.
链接地址: http://www.djcxy.com/p/90386.html上一篇: 如何压缩已推送到远程的特定提交?
下一篇: 贝宝“登录”整合重定向