googleapis
Advanced tools
Comparing version 0.2.9-alpha to 0.2.10-alpha
@@ -50,4 +50,5 @@ /** | ||
this.opts = opt_opts || {}; | ||
if (!fs.existsSync(Cache.TMP_DIR_)) { | ||
fs.mkdirSync(Cache.TMP_DIR_, '700'); | ||
this.opts.path = this.opts.path || Cache.TMP_DIR_; | ||
if (!fs.existsSync(this.opts.path)) { | ||
fs.mkdirSync(this.opts.path, '700'); | ||
} | ||
@@ -105,3 +106,3 @@ } | ||
Cache.prototype.getPath = function(api) { | ||
return Cache.TMP_DIR_ + '/' + api.name + api.version; | ||
return this.opts.path + '/' + api.name + api.version; | ||
}; | ||
@@ -108,0 +109,0 @@ |
@@ -31,2 +31,3 @@ /** | ||
this.clients = []; | ||
this.ops = {}; | ||
this.authClient = null; | ||
@@ -70,4 +71,4 @@ } | ||
function GoogleApis() { | ||
this.opts = {}; | ||
this.toBeDiscovered = []; | ||
this.cache = new Cache(); | ||
this.transporter = exports.Transporter || new DefaultTransporter(); | ||
@@ -153,2 +154,3 @@ this.authClient = null; | ||
var that = this; | ||
var cache = new Cache(this.opts.cache); | ||
@@ -163,3 +165,3 @@ if (api.opts && api.opts.localDiscoveryFilePath) { | ||
if (!err && data) { | ||
that.cache.write(api, data); | ||
cache.write(api, data); | ||
client = new Client(data); | ||
@@ -170,3 +172,3 @@ } | ||
var data = this.cache.load(api); | ||
var data = cache.load(api); | ||
if (data) { | ||
@@ -198,3 +200,3 @@ generateClient(null, data); | ||
* Generates the discovery url. | ||
* @param {String} api An object to represent the api name, version and opts. | ||
* @param {String} api An object to represent the api name, version and opts. | ||
* @return {string} discoveryUrl. | ||
@@ -223,7 +225,17 @@ */ | ||
/** | ||
* Adds options. | ||
* | ||
* @param {object} Options. | ||
* @return {GoogleApis} Returns itself. | ||
*/ | ||
GoogleApis.prototype.withOpts = function(opts) { | ||
this.opts = opts; | ||
return this; | ||
}; | ||
/** | ||
* Adds global auth client. | ||
* | ||
* @param {auth.AuthClient} client An auth client instance. | ||
* | ||
* @return {Client} Returns itself. | ||
* @return {GoogleApis} Returns itself. | ||
*/ | ||
@@ -230,0 +242,0 @@ GoogleApis.prototype.withAuthClient = function(client) { |
{ | ||
"name": "googleapis", | ||
"version": "0.2.9-alpha", | ||
"version": "0.2.10-alpha", | ||
"author": "Google Inc.", | ||
@@ -5,0 +5,0 @@ "description": "Google APIs Client Library for Node.js", |
@@ -5,3 +5,3 @@ # google-api-nodejs-client [alpha] | ||
`google-api-nodejs-client` is the Google's officially supported | ||
`google-api-nodejs-client` is Google's officially supported | ||
[node.js](http://nodejs.org/) client | ||
@@ -48,2 +48,15 @@ library for accessing Google APIs, it also supports authorization and | ||
#### Discovery Document Caching | ||
Discovery documents are being cached for 5 minutes locally. | ||
You can configure the directory used to store cached discovery | ||
files by using the `cache.path` option. | ||
~~~~ js | ||
googleapis | ||
.discover('plus', 'v3') | ||
.withOpts({ cache: { path: '<path>' })) | ||
.execute(); | ||
~~~~ | ||
### API Client | ||
@@ -82,3 +95,3 @@ | ||
Following sample loads a client for URL Shortener and retrieves the long url | ||
The following sample loads a client for URL Shortener and retrieves the long url | ||
of the given short url: | ||
@@ -119,3 +132,3 @@ | ||
This client comes with an OAuth2 client allows you to retrieve an access token and | ||
This client comes with an OAuth2 client that allows you to retrieve an access token and | ||
refreshes the token and re-try the request seamlessly if token is expired. The | ||
@@ -131,3 +144,3 @@ basics of Google's OAuth 2.0 implementation is explained on | ||
In order to ask for permissions from user to retrieve an access token, you | ||
In order to ask for permissions from a user to retrieve an access token, you | ||
should redirect them to a consent page. In order to create a consent page | ||
@@ -143,3 +156,3 @@ URL: | ||
// generates a url allows offline access and asks permissions | ||
// generates a url that allows offline access and asks permissions | ||
// for Google+ scope. | ||
@@ -153,3 +166,3 @@ var url = oauth2Client.generateAuthUrl({ | ||
#### Retrieving Tokens | ||
Once user has given permissions on the consent page, Google will redirect | ||
Once a user has given permissions on the consent page, Google will redirect | ||
the page to the redirect url you have provided with a code query parameter. | ||
@@ -156,0 +169,0 @@ |
1063
242
50017
13