@@ -101,7 +101,7 @@ export class ApplicationTokenCredentials {
101101 if ( ! this . token_deferred || force ) {
102102 if ( this . scheme === AzureModels . Scheme . ManagedServiceIdentity )
103103 {
104- this . token_deferred = this . _getMSIAuthorizationToken ( 0 , 0 ) ;
104+ this . token_deferred = ApplicationTokenCredentials . getMSIAuthorizationToken ( 0 , 0 , this . baseUrl , this . msiClientId ) ;
105105 }
106106 else
107107 {
@@ -120,14 +120,14 @@ export class ApplicationTokenCredentials {
120120 return this . clientId ;
121121 }
122122
123- private _getMSIAuthorizationToken ( retyCount : number , timeToWait : number ) : Q . Promise < string > {
123+ public static getMSIAuthorizationToken ( retyCount : number , timeToWait : number , baseUrl : string , msiClientId ?: string ) : Q . Promise < string > {
124124 var deferred = Q . defer < string > ( ) ;
125125 let webRequest = new webClient . WebRequest ( ) ;
126126 webRequest . method = "GET" ;
127127 let apiVersion = "2018-02-01" ;
128128 const retryLimit = 5 ;
129- let msiClientId = this . msiClientId ? "&client_id=" + this . msiClientId : "" ;
130- webRequest . uri = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=" + apiVersion + "&resource=" + this . baseUrl + msiClientId ;
129+ msiClientId = msiClientId ? "&client_id=" + msiClientId : "" ;
130+ webRequest . uri = "http://169.254.169.254/metadata/identity/oauth2/token?api-version=" + apiVersion + "&resource=" + baseUrl + msiClientId ;
131131 webRequest . headers = {
132132 "Metadata" : true
133133 } ;
@@ -145,7 +145,7 @@ export class ApplicationTokenCredentials {
145145 let waitedTime = 2000 + timeToWait * 2 ;
146146 retyCount += 1 ;
147147 setTimeout ( ( ) => {
148- deferred . resolve ( this . _getMSIAuthorizationToken ( retyCount , waitedTime ) ) ;
148+ deferred . resolve ( this . getMSIAuthorizationToken ( retyCount , waitedTime , baseUrl , msiClientId ) ) ;
149149 } , waitedTime ) ;
150150 }
151151 else
0 commit comments