Repository navigation
Expand file tree
/
Copy pathrdio.js
More file actions
68 lines (63 loc) · 1.83 KB
/
Copy pathrdio.js
File metadata and controls
68 lines (63 loc) · 1.83 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
/***
*
* | |o
* ,---.,---.,---|,---. ,---.,---|.,---.
* | || || ||---'---| | ||| |
* ` '`---'`---'`---' ` `---'``---'
*
* Author: Troy Whiteley <troy@somanyscientists.com>
* Homepage: http://github.com/dawnerd/
* License: CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/)
*
*
* Config options:
* rdio_api_key
* rdio_api_shared
* callback_url - URL user will be redirected to upon login
*/
module.exports = function(config, oauth) {
if(typeof oauth == 'undefined') {
var oauth = require('oauth').OAuth;
}
config.rdio_oauth_request = 'http://api.rdio.com/oauth/request_token';
config.rdio_oauth_access = 'http://api.rdio.com/oauth/access_token';
config.rdio_oauth_auth = 'https://www.rdio.com/oauth/authorize?oauth_token=';
config.rdio_api = 'http://api.rdio.com/1/';
//setup oauth
var oa = new oauth(
config.rdio_oauth_request,
config.rdio_oauth_access,
config.rdio_api_key,
config.rdio_api_shared,
"1.0", config.callback_url, "HMAC-SHA1");
//public methods
return {
getRequestToken: function(callback) {
oa.getOAuthRequestToken(callback);
},
getAccessToken: function(auth_token, auth_token_secret, oauth_verifier, callback) {
oa.getOAuthAccessToken(auth_token, auth_token_secret, oauth_verifier, callback);
},
getPlaybackToken: function(auth_token, auth_token_secret, host, callback) {
this.api(
auth_token,
auth_token_secret,
{
method: 'getPlaybackToken',
domain: encodeURIComponent(host)
},
callback
);
},
api: function(auth_token, auth_token_secret, data, callback) {
oa.post(
config.rdio_api,
auth_token,
auth_token_secret,
data,
null,
callback
);
}
};
};