-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiscogsTest.html
More file actions
73 lines (64 loc) · 1.88 KB
/
discogsTest.html
File metadata and controls
73 lines (64 loc) · 1.88 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
<html>
<head>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript" src="oauth.js"></script>
<script type="text/javascript" src="sha1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var USER_AGENT = "VinylesDansLaPoche/0.1 +http://grendel.free.fr";
var ROOT = "http://api.discogs.com";
var CONSUMER_KEY = "LWaSecDcEnrzaHxmLSxq";
var CONSUMER_SECRET = "VoWcrQoFFyMCGnfjzzOWnQpUMXMsaYKg";
var REQUEST_TOKEN_URL = ROOT + "/oauth/request_token";
var AUTHORIZE_URL = "http://www.discogs.com/oauth/authorize";
var ACCESS_TOKEN_URL = ROOT + "/oauth/access_token";
var IDENTITY_URL = ROOT + "/oauth/identity";
var HEADERS = {
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "VinylesDansLaPoche/0.1 +http://grendel.free.fr",
"Origin": "localhost"
};
var oauth = {
action: REQUEST_TOKEN_URL,
method: "POST",
parameters: {
oauth_consumer_key: CONSUMER_KEY,
oauth_signature_method: "HMAC-SHA1",
oauth_signature: "",
oauth_timestamp: "",
oauth_nonce: ""
}
};
var accessor = {
consumerSecret: CONSUMER_SECRET,
tokenSecret: ""
};
OAuth.setTimestampAndNonce(oauth);
OAuth.SignatureMethod.sign(oauth, accessor);
// HEADERS.Authorization = 'OAuth realm="'+ROOT+'", \
// oauth_consumer_key="'+CONSUMER_KEY+'", \
// oauth_token="'+CONSUMER_SECRET+'", \
// oauth_signature_method="HMAC-SHA1", \
// oauth_timestamp="137131201", \
// oauth_nonce="7d8f3e4a"';
$.ajax({
beforeSend: function(xhr) {
xhr.setRequestHeader("User-Agent", USER_AGENT);
xhr.setRequestHeader("Origin", "localhost");
},
type: "POST",
data: oauth.parameters,
url: REQUEST_TOKEN_URL,
success: function(data){
console.debug(data);
},
complete: function(data){
console.debug(data);
}
});
});
</script>
</head>
<body>
</body>
</html>