-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (91 loc) · 3.62 KB
/
index.html
File metadata and controls
96 lines (91 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Login with Amazon</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css"
integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
</head>
<body>
<div id="amazon-root"></div>
<script type="text/javascript">
function getURLParameter(name, source) {
console.log("getURLParameter", name, source);
return decodeURIComponent((new RegExp('[?|&|#]' + name + '=' +
'([^&]+?)(&|#|;|$)').exec(source) || [, ""])[1].replace(/\+/g, '%20')) || null;
}
var accessToken = getURLParameter("access_token", location.href);
if (typeof accessToken === 'string' && accessToken.match(/^Atza/)) {
document.cookie = "amazon_Login_accessToken=" + accessToken +";secure;path=/";
}
window.onAmazonLoginReady = function() {
amazon.Login.setClientId('amzn1.application-oa2-client.242a859efb5f47f09847f3f0aebd50ca');
amazon.Login.setRegion('APAC');
amazon.Login.setLanguage('ja_JP');
//if has accessToken retrieveProfile and set.
if (accessToken) {
amazon.Login.retrieveProfile(accessToken, function (response){
if (response.success) {
document.getElementById('profile').innerHTML =
response.profile.Name + " : " + response.profile.PostalCode
+ "<br />"
+ response.profile.PrimaryEmail;
}
});
}
};
(function(d) {
var a = d.createElement('script');
a.type = 'text/javascript';
a.async = true;
a.id = 'amazon-login-sdk';
a.src = 'https://api-cdn.amazon.com/sdk/login1.js';
d.getElementById('amazon-root').appendChild(a);
})(document);
</script>
<div class="container">
<div class="jumbotron">
<h2>Example with original button</h2>
<div class="row">
<div class="col-md-6 text-right">
<a href="#" id="LoginWithAmazon">
<img border="0" alt="Login with Amazon"
src="https://images-na.ssl-images-amazon.com/images/G/01/EP/offAmazonPayments/jp/live/prod/image/lwa/gold/medium/LwA.png"
/>
</a>
</div>
<div class="col-md-6">
<button type="button" name="button" id="AmazonLogoutButton" class="btn btn-danger"> Logout</button>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<h4 id="profile"></h4>
</div>
</div>
</div>
</div>
<script type="text/javascript">
document.getElementById('LoginWithAmazon').onclick = function() {
options = {
scope : 'profile postal_code',
state: "test:aaaa",
language:"jp",
interactive:"always"
};
amazon.Login.authorize(options, "/");
return false;
};
document.getElementById('AmazonLogoutButton').addEventListener("click", function () {
amazon.Login.logout();
// document.cookie = "amazon_Login_accessToken=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
window.location.href = "/index.html";
});
</script>
</body>
</html>