Skip to content

Commit 270ed8b

Browse files
amaswauwmmrazikMaxim Zaytsev
authored
Made getMSIAuthorizationToken a public function able to be accessed from other classes (#16818)
Co-authored-by: Martin Mrazik <[email protected]> Co-authored-by: Maxim Zaytsev <[email protected]>
1 parent 1606901 commit 270ed8b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

common-npm-packages/azure-arm-rest-v2/azure-arm-common.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export declare class ApplicationTokenCredentials {
1919
getToken(force?: boolean): Q.Promise<string>;
2020
getDomain(): string;
2121
getClientId(): string;
22-
private _getMSIAuthorizationToken(retyCount, timeToWait);
22+
public static getMSIAuthorizationToken(retyCount, timeToWait, baseUrl, msiClientId?);
2323
private _getSPNAuthorizationToken();
2424
private _getSPNAuthorizationTokenFromCertificate();
2525
private _getSPNAuthorizationTokenFromKey();

common-npm-packages/azure-arm-rest-v2/azure-arm-common.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

common-npm-packages/azure-arm-rest-v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "azure-pipelines-tasks-azure-arm-rest-v2",
3-
"version": "2.208.0",
3+
"version": "2.210.0",
44
"description": "Common Lib for Azure ARM REST apis",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)