-
Notifications
You must be signed in to change notification settings - Fork 0
/
douban_client.js
32 lines (27 loc) · 1.19 KB
/
douban_client.js
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
Douban = {};
Douban.requestCredential = function (options, credentialRequestCompleteCallback) {
if (!credentialRequestCompleteCallback && typeof options === 'function') {
credentialRequestCompleteCallback = options;
options = {};
}
var config = ServiceConfiguration.configurations.findOne({service: 'douban'});
if (!config) {
credentialRequestCompleteCallback && credentialRequestCompleteCallback(
new ServiceConfiguration.ConfigError());
return;
}
var credentialToken = Random.secret(),
loginStyle = OAuth._loginStyle('weibo', config, options),
loginUrl = 'https://www.douban.com/service/auth2/auth' +
'?response_type=code' +
'&client_id=' + config.clientId +
'&redirect_uri=' + OAuth._redirectUri('douban', config, null, {replaceLocalhost: config.replaceLocalhost}) +
'&state=' + OAuth._stateParam(loginStyle, credentialToken);
OAuth.launchLogin({
loginService: 'douban',
loginStyle: loginStyle,
loginUrl: loginUrl,
credentialRequestCompleteCallback: credentialRequestCompleteCallback,
credentialToken: credentialToken
});
}