我一直在努力整合亚马逊登录和支付我一直在开发的网站,它工作得很好,除了我想使用重定向经验而不是弹出窗口,以便我的应用程序可以在移动设备上工作。但是,我无法让它工作。我已经去了salescentral上的应用程序,并添加到我允许的Javascript Origins:
https://localhost:8443/
https://mysite.co/
https://mysitedev-env.elasticbeanstalk.com/
同样,在Allowed Return URLS:
下https://localhost:8443/pay/amazon_pay
https://mysite.co/pay/amazon_pay
https://mysitedev-env.elasticbeanstalk.com/pay/amazon_pay
但是当我从https://localhost:8443/点击按钮时,我收到错误:
Error Summary
400 Bad Request
The redirect URI you provided has not been whitelisted for your application
Request Details
client_id=amzn1.application-oa2-client.1fad4ae9338847a094443ce982cd7c96
redirect_uri=https%3A%2F%2Flocalhost%3A8443%2Fpay%2Famazon_pay%3Fpage%3Dlogin-pay%26extra_amount%3D%26phrase%3Dblack%2520black%2520ocean
response_type=token
scope=profile%20payments%3Awidget
language=
ui_locales=
sandbox=true
我很确定这是我白名单的问题,而不是我的代码,但如果有帮助,我的代码看起来像:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><script type='text/javascript'>
function getURLParameter(name, source) {
return decodeURIComponent((new RegExp('[?|&|#]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(source)||[,""])[1].replace(/\+/g,'%20'))||null;
}
var accessToken = getURLParameter("access_token", location.hash);
if (typeof accessToken === 'string' && accessToken.match(/^Atza/)) {
document.cookie = "amazon_Login_accessToken=" + accessToken + ";secure";
}
window.onAmazonLoginReady = function() {
amazon.Login.setClientId('${client_id}');
amazon.Login.setUseCookie(true);
};
function launchAmazon(){
console.log("Amazon script loaded.");
var session = "${session}";
var access_token = "${access_token}";
if (session == null || access_token == null) {
alert("Missing query string parameters from request, verify that access_token & session are present");
}
var authRequest;
OffAmazonPayments.Button("login_widget", "${seller_id}", {
sellerId: '${seller_id}',
useAmazonAddressBook: true,
type: "PwA",
size: "large",
onSignIn: function(order){
},
authorization: function(order){
var loginOptions = {scope: 'profile payments:widget',popup: false};
authRequest = amazon.Login.authorize(loginOptions, "/pay/amazon_pay?page=login-pay&extra_amount=${extra_amount}&phrase=${phrase}");
},
onError: function(error) {
alert(error.getErrorCode() + ": " + error.getErrorMessage());
},
});
}
$.getScript("https://static-na.payments-amazon.com/OffAmazonPayments/us${sandbox}/js/Widgets.js?sellerId=${seller_id}")
.done(launchAmazon)
.fail(function(jqxhr, settings, exception){
debugger;
console.log(exception);
});
</script>
<div id="login_widget_holder" class="amazon_widget_holder">
<div id="login_widget" class="amazon_widget"></div>
</div>