@@ -64,7 +64,7 @@ var Client = exports.Client = function(args){
6464 }
6565} ;
6666
67- Client . prototype . request = function ( opts , callback ) {
67+ Client . prototype . request = function ( opts , callback , authorization ) {
6868 var client = this ;
6969 var contentBody = null ;
7070
@@ -102,8 +102,9 @@ Client.prototype.request = function(opts, callback) {
102102
103103 opts . headers [ client . headers . USER_AGENT ] = this . userAgent ;
104104
105- if ( client . authorization )
106- opts . headers [ client . headers . AUTHORIZATION ] = this . authorization ;
105+ var authToUse = authorization || client . authorization ;
106+ if ( authToUse )
107+ opts . headers [ client . headers . AUTHORIZATION ] = authToUse ;
107108
108109 if ( opts . body )
109110 contentBody = opts . body ;
@@ -239,6 +240,10 @@ Client.prototype.statementResource = function(opts) {
239240 if ( opts . timezone )
240241 header [ client . headers . TIME_ZONE ] = opts . timezone ;
241242
243+ if ( opts . authorization ) {
244+ header [ client . headers . AUTHORIZATION ] = opts . authorization
245+ }
246+
242247
243248 var fetch_info = opts . info || false ;
244249
@@ -358,7 +363,7 @@ Client.prototype.statementResource = function(opts) {
358363 } else {
359364 error_callback ( { message : "query fetch canceled by operation" } ) ;
360365 }
361- } ) ;
366+ } , opts . authorization ) ;
362367 return ;
363368 }
364369 current_req = client . request ( uri_obj , function ( error , code , response ) {
@@ -446,12 +451,12 @@ Client.prototype.statementResource = function(opts) {
446451 if ( fetch_info && response . infoUri ) {
447452 client . request ( response . infoUri , function ( error , code , response ) {
448453 success_callback ( null , finishedStats , response ) ;
449- } ) ;
454+ } , opts . authorization ) ;
450455 }
451456 else {
452457 success_callback ( null , finishedStats ) ;
453458 }
454- } ) ;
459+ } , opts . authorization ) ;
455460 } ;
456461 fetch ( { method : 'POST' , path : '/v1/statement' , headers : header , body : opts . query , user : opts . user } ) ;
457462} ;
0 commit comments