Skip to content
Browse files

added tokenType config option

  • Loading branch information...
1 parent 0e17302 commit e721b71254860490edf0b09291201eab145a76cd @bsphere bsphere committed Jan 31, 2013
Showing with 19 additions and 4 deletions.
  1. +7 −0 README.md
  2. +9 −2 lib/ga.js
  3. +3 −2 package.json
View
7 README.md
@@ -59,6 +59,9 @@ If you have already gotten permission from a user, you can simply use the oAuth
util.debug(JSON.stringify(entries));
});
+* You can specify the type of token by setting 'tokenType', default is 'Bearer'.
+
+See [node-gapitoken][gapi] for easy services account Server to Server authorization flow.
Rudamentary API
============
@@ -91,6 +94,7 @@ Contributors
* [Brian Zeligson][beezee] - Updates for a more recent version of node. Also makes use of better selectors.
+* [Gal Ben-Haim][bsphere]
License
============
@@ -99,3 +103,6 @@ see license file
[beezee]:https://github.com/beezee
+[bsphere]:https://github.com/bsphere
+
+[gapi]:https://github.com/bsphere/node-gapitoken
View
11 lib/ga.js
@@ -16,14 +16,21 @@ function GA(config) {
if (config) {
if ('user' in config) {
this.user = config.user;
+ this.tokenType = 'GoogleLogin';
}
if ('password' in config) {
this.password = config.password;
}
+ this.token = ('token' in config) ? config.token : null;
+ if ('token' in config) {
+ this.tokenType = config.tokenType || 'Bearer';
+ }
+ if ('token' in config && ('user' in config || 'password' in config)) {
+ throw Error("Invalid config.");
+ }
} else {
throw Error("No config given.");
}
- this.token = ('token' in config) ? config.token : null;
};
inherits(GA, emitter);
@@ -102,7 +109,7 @@ GA.prototype.get = function(options, cb) {
path: data_url,
method: 'GET',
headers: {
- Authorization:"Bearer "+this.token,
+ Authorization: this.tokenType + " " + this.token,
"GData-Version": 2
}
};
View
5 package.json
@@ -2,11 +2,12 @@
"name": "googleanalytics",
"main": "./lib/ga",
"description": "Google Analytics library.",
- "version": "0.3.1",
+ "version": "0.3.2",
"author": "Nick Campbell (http://github.com/ncb000gt)",
"contributors": [
{ "name": "Brian Zeligson (http://github.com/beezee)", "email": "brian.zeligson@gmail.com" },
- { "name": "Mike Schierberl (http://github.com/mschierberl)", "email": "mike@schierberl.com" }
+ { "name": "Mike Schierberl (http://github.com/mschierberl)", "email": "mike@schierberl.com" },
+ { "name": "Gal Ben-Haim (http://github.com/bsphere", "email": "gbenhaim@gmail.com"}
],
"engines": { "node": ">= 0.4.0" },
"repository": {

0 comments on commit e721b71

Please sign in to comment.
Something went wrong with that request. Please try again.