-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoauth.js
More file actions
26 lines (21 loc) · 742 Bytes
/
oauth.js
File metadata and controls
26 lines (21 loc) · 742 Bytes
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
/**
* Created by shuis on 2017/5/27.
*/
const OAuth = require('oauth-1.0a');
Object.assign(OAuth.prototype, {
authHeader(request_data){
let header = this.toHeader(request_data);
let header_value = header.Authorization;
let xauth = {
x_auth_username: request_data.x_auth_username,
x_auth_password: request_data.x_auth_password,
x_auth_mode: request_data.x_auth_mode,
};
for(let key in xauth){
header_value += this.percentEncode(key) + '="' + this.percentEncode(xauth[key]) + '"' + this.parameter_seperator;
}
header.Authorization = header_value.substr(0, header_value.length - this.parameter_seperator.length); //cut the last chars
return header;
}
});
module.exports = OAuth;