mirror of
https://github.com/HackPlan/google-auth-library-nodejs.git
synced 2026-04-30 04:35:46 +08:00
add transporter_options
This commit is contained in:
@@ -22,6 +22,7 @@ var noop = require('lodash.noop');
|
|||||||
var PemVerifier = require('./../pemverifier.js');
|
var PemVerifier = require('./../pemverifier.js');
|
||||||
var querystring = require('querystring');
|
var querystring = require('querystring');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
var DefaultTransporter = require('./../transporters.js');
|
||||||
|
|
||||||
var certificateCache = null;
|
var certificateCache = null;
|
||||||
var certificateExpiry = null;
|
var certificateExpiry = null;
|
||||||
@@ -35,7 +36,7 @@ var certificateExpiry = null;
|
|||||||
* @param {Object} opt_opts optional options for overriding the given parameters.
|
* @param {Object} opt_opts optional options for overriding the given parameters.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function OAuth2Client(clientId, clientSecret, redirectUri, opt_opts) {
|
function OAuth2Client(clientId, clientSecret, redirectUri, opt_opts, transporter_options) {
|
||||||
OAuth2Client.super_.call(this);
|
OAuth2Client.super_.call(this);
|
||||||
|
|
||||||
this.clientId_ = clientId;
|
this.clientId_ = clientId;
|
||||||
@@ -43,6 +44,7 @@ function OAuth2Client(clientId, clientSecret, redirectUri, opt_opts) {
|
|||||||
this.redirectUri_ = redirectUri;
|
this.redirectUri_ = redirectUri;
|
||||||
this.opts = opt_opts || {};
|
this.opts = opt_opts || {};
|
||||||
this.credentials = {};
|
this.credentials = {};
|
||||||
|
this.transporter = new DefaultTransporter(transporter_options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -152,7 +154,7 @@ OAuth2Client.prototype.getToken = function(code, opt_callback) {
|
|||||||
}
|
}
|
||||||
var done = opt_callback || noop;
|
var done = opt_callback || noop;
|
||||||
done(err, tokens, response);
|
done(err, tokens, response);
|
||||||
}, this.opts);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ var utils = require('../lib/utils.js');
|
|||||||
* Default transporter constructor.
|
* Default transporter constructor.
|
||||||
* Wraps request and callback functions.
|
* Wraps request and callback functions.
|
||||||
*/
|
*/
|
||||||
function DefaultTransporter() {}
|
function DefaultTransporter(options) {
|
||||||
|
this.options = options || {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default user agent.
|
* Default user agent.
|
||||||
@@ -54,9 +56,9 @@ DefaultTransporter.prototype.configure = function(opts) {
|
|||||||
* @param {Function=} opt_callback Optional callback.
|
* @param {Function=} opt_callback Optional callback.
|
||||||
* @return {Request} Request object
|
* @return {Request} Request object
|
||||||
*/
|
*/
|
||||||
DefaultTransporter.prototype.request = function(opts, opt_callback, extra_opts) {
|
DefaultTransporter.prototype.request = function(opts, opt_callback) {
|
||||||
opts = this.configure(opts);
|
opts = this.configure(opts);
|
||||||
opts = utils.extend(opts, extra_opts);
|
opts = utils.extend(opts, this.options);
|
||||||
return request(opts.uri || opts.url, opts, this.wrapCallback_(opt_callback));
|
return request(opts.uri || opts.url, opts, this.wrapCallback_(opt_callback));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user