@@ -232,31 +232,27 @@ Function ConfigureApplications
232
232
233
233
# Create the service AAD application
234
234
Write-Host " Creating the AAD application (msal-node-api)"
235
+
235
236
# create the application
236
237
$serviceAadApplication = New-MgApplication - DisplayName " msal-node-api" `
237
- - Web `
238
- @ { `
239
- } `
240
238
- Api `
241
239
@ { `
242
240
RequestedAccessTokenVersion = 2 `
243
241
} `
244
242
- SignInAudience AzureADMyOrg `
245
243
# end of command
246
- $currentAppId = $serviceAadApplication.AppId
247
- $currentAppObjectId = $serviceAadApplication.Id
248
-
249
- $serviceIdentifierUri = ' api://' + $currentAppId
250
- Update-MgApplication - ApplicationId $currentAppObjectId - IdentifierUris @ ($serviceIdentifierUri )
244
+ $serviceIdentifierUri = ' api://' + $serviceAadApplication.AppId
245
+ Update-MgApplication - ApplicationId $serviceAadApplication.Id - IdentifierUris @ ($serviceIdentifierUri )
251
246
252
- # create the service principal of the newly created application
247
+ # create the service principal of the newly created application
248
+ $currentAppId = $serviceAadApplication.AppId
253
249
$serviceServicePrincipal = New-MgServicePrincipal - AppId $currentAppId - Tags {WindowsAzureActiveDirectoryIntegratedApp}
254
250
255
251
# add the user running the script as an app owner if needed
256
- $owner = Get-MgApplicationOwner - ApplicationId $currentAppObjectId
252
+ $owner = Get-MgApplicationOwner - ApplicationId $serviceAadApplication .Id
257
253
if ($owner -eq $null )
258
254
{
259
- New-MgApplicationOwnerByRef - ApplicationId $currentAppObjectId - BodyParameter = @ {" @odata.id" = " htps://graph.microsoft.com/v1.0/directoryObjects/$user .ObjectId" }
255
+ New-MgApplicationOwnerByRef - ApplicationId $serviceAadApplication .Id - BodyParameter = @ {" @odata.id" = " htps://graph.microsoft.com/v1.0/directoryObjects/$user .ObjectId" }
260
256
Write-Host " '$ ( $user.UserPrincipalName ) ' added as an application owner to app '$ ( $serviceServicePrincipal.DisplayName ) '"
261
257
}
262
258
@@ -271,7 +267,7 @@ Function ConfigureApplications
271
267
272
268
$newClaim = CreateOptionalClaim - name " idtyp"
273
269
$optionalClaims.AccessToken += ($newClaim )
274
- Update-MgApplication - ApplicationId $currentAppObjectId - OptionalClaims $optionalClaims
270
+ Update-MgApplication - ApplicationId $serviceAadApplication .Id - OptionalClaims $optionalClaims
275
271
276
272
# rename the user_impersonation scope if it exists to match the readme steps or add a new scope
277
273
@@ -285,10 +281,10 @@ Function ConfigureApplications
285
281
# disable the scope
286
282
$scope.IsEnabled = $false
287
283
$scopes.Add ($scope )
288
- Update-MgApplication - ApplicationId $currentAppObjectId - Api @ {Oauth2PermissionScopes = @ ($scopes )}
284
+ Update-MgApplication - ApplicationId $serviceAadApplication .Id - Api @ {Oauth2PermissionScopes = @ ($scopes )}
289
285
290
286
# clear the scope
291
- Update-MgApplication - ApplicationId $currentAppObjectId - Api @ {Oauth2PermissionScopes = @ ()}
287
+ Update-MgApplication - ApplicationId $serviceAadApplication .Id - Api @ {Oauth2PermissionScopes = @ ()}
292
288
}
293
289
294
290
$scopes = New-Object System.Collections.Generic.List[Microsoft.Graph.PowerShell.Models.MicrosoftGraphPermissionScope ]
@@ -301,46 +297,45 @@ Function ConfigureApplications
301
297
$scopes.Add ($scope )
302
298
303
299
# add/update scopes
304
- Update-MgApplication - ApplicationId $currentAppObjectId - Api @ {Oauth2PermissionScopes = @ ($scopes )}
300
+ Update-MgApplication - ApplicationId $serviceAadApplication .Id - Api @ {Oauth2PermissionScopes = @ ($scopes )}
305
301
Write-Host " Done creating the service application (msal-node-api)"
306
302
307
303
# URL of the AAD application in the Azure portal
308
- # Future? $servicePortalUrl = "https://portal.azure.com/#@"+$tenantName+"/blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Overview/appId/"+$currentAppId +"/objectId/"+$currentAppObjectId +"/isMSAApp/"
309
- $servicePortalUrl = " https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/CallAnAPI/appId/" + $currentAppId + " /objectId/" + $currentAppObjectId + " /isMSAApp/"
304
+ # Future? $servicePortalUrl = "https://portal.azure.com/#@"+$tenantName+"/blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Overview/appId/"+$serviceAadApplication.AppId +"/objectId/"+$serviceAadApplication.Id +"/isMSAApp/"
305
+ $servicePortalUrl = " https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/CallAnAPI/appId/" + $serviceAadApplication .AppId + " /objectId/" + $serviceAadApplication .Id + " /isMSAApp/"
310
306
311
307
Add-Content - Value " <tr><td>service</td><td>$currentAppId </td><td><a href='$servicePortalUrl '>msal-node-api</a></td></tr>" - Path createdApps.html
312
308
313
309
# print the registered app portal URL for any further navigation
314
- Write-Host " Successfully registered and configured that app registration for 'msal-node-api' at `n $servicePortalUrl " - ForegroundColor Green
310
+ Write-Host " Successfully registered and configured that app registration for 'msal-node-api' at `n $servicePortalUrl " - ForegroundColor Red
315
311
316
312
# Create the client AAD application
317
313
Write-Host " Creating the AAD application (msal-react-spa)"
314
+
318
315
# create the application
319
316
$clientAadApplication = New-MgApplication - DisplayName " msal-react-spa" `
320
317
- Spa `
321
318
@ { `
322
- RedirectUris = " http://localhost:3000/ " ; `
319
+ RedirectUris = " http://localhost:3000" ; `
323
320
} `
324
321
- Api `
325
322
@ { `
326
323
RequestedAccessTokenVersion = 2 `
327
324
} `
328
325
- SignInAudience AzureADMyOrg `
329
326
# end of command
330
- $currentAppId = $clientAadApplication.AppId
331
- $currentAppObjectId = $clientAadApplication.Id
332
-
333
- $clientIdentifierUri = ' api://' + $currentAppId
334
- Update-MgApplication - ApplicationId $currentAppObjectId - IdentifierUris @ ($clientIdentifierUri )
327
+ $clientIdentifierUri = ' api://' + $clientAadApplication.AppId
328
+ Update-MgApplication - ApplicationId $clientAadApplication.Id - IdentifierUris @ ($clientIdentifierUri )
335
329
336
- # create the service principal of the newly created application
330
+ # create the service principal of the newly created application
331
+ $currentAppId = $clientAadApplication.AppId
337
332
$clientServicePrincipal = New-MgServicePrincipal - AppId $currentAppId - Tags {WindowsAzureActiveDirectoryIntegratedApp}
338
333
339
334
# add the user running the script as an app owner if needed
340
- $owner = Get-MgApplicationOwner - ApplicationId $currentAppObjectId
335
+ $owner = Get-MgApplicationOwner - ApplicationId $clientAadApplication .Id
341
336
if ($owner -eq $null )
342
337
{
343
- New-MgApplicationOwnerByRef - ApplicationId $currentAppObjectId - BodyParameter = @ {" @odata.id" = " htps://graph.microsoft.com/v1.0/directoryObjects/$user .ObjectId" }
338
+ New-MgApplicationOwnerByRef - ApplicationId $clientAadApplication .Id - BodyParameter = @ {" @odata.id" = " htps://graph.microsoft.com/v1.0/directoryObjects/$user .ObjectId" }
344
339
Write-Host " '$ ( $user.UserPrincipalName ) ' added as an application owner to app '$ ( $clientServicePrincipal.DisplayName ) '"
345
340
}
346
341
@@ -356,21 +351,21 @@ Function ConfigureApplications
356
351
# disable the scope
357
352
$scope.IsEnabled = $false
358
353
$scopes.Add ($scope )
359
- Update-MgApplication - ApplicationId $currentAppObjectId - Api @ {Oauth2PermissionScopes = @ ($scopes )}
354
+ Update-MgApplication - ApplicationId $clientAadApplication .Id - Api @ {Oauth2PermissionScopes = @ ($scopes )}
360
355
361
356
# clear the scope
362
- Update-MgApplication - ApplicationId $currentAppObjectId - Api @ {Oauth2PermissionScopes = @ ()}
357
+ Update-MgApplication - ApplicationId $clientAadApplication .Id - Api @ {Oauth2PermissionScopes = @ ()}
363
358
}
364
359
365
360
$scopes = New-Object System.Collections.Generic.List[Microsoft.Graph.PowerShell.Models.MicrosoftGraphPermissionScope ]
366
361
367
362
# add/update scopes
368
- Update-MgApplication - ApplicationId $currentAppObjectId - Api @ {Oauth2PermissionScopes = @ ($scopes )}
363
+ Update-MgApplication - ApplicationId $clientAadApplication .Id - Api @ {Oauth2PermissionScopes = @ ($scopes )}
369
364
Write-Host " Done creating the client application (msal-react-spa)"
370
365
371
366
# URL of the AAD application in the Azure portal
372
- # Future? $clientPortalUrl = "https://portal.azure.com/#@"+$tenantName+"/blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Overview/appId/"+$currentAppId +"/objectId/"+$currentAppObjectId +"/isMSAApp/"
373
- $clientPortalUrl = " https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/CallAnAPI/appId/" + $currentAppId + " /objectId/" + $currentAppObjectId + " /isMSAApp/"
367
+ # Future? $clientPortalUrl = "https://portal.azure.com/#@"+$tenantName+"/blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/Overview/appId/"+$clientAadApplication.AppId +"/objectId/"+$clientAadApplication.Id +"/isMSAApp/"
368
+ $clientPortalUrl = " https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationMenuBlade/CallAnAPI/appId/" + $clientAadApplication .AppId + " /objectId/" + $clientAadApplication .Id + " /isMSAApp/"
374
369
375
370
Add-Content - Value " <tr><td>client</td><td>$currentAppId </td><td><a href='$clientPortalUrl '>msal-react-spa</a></td></tr>" - Path createdApps.html
376
371
# Declare a list to hold RRA items
@@ -387,21 +382,21 @@ Function ConfigureApplications
387
382
# $requiredResourcesAccess.Count
388
383
# $requiredResourcesAccess
389
384
390
- Update-MgApplication - ApplicationId $currentAppObjectId - RequiredResourceAccess $requiredResourcesAccess
385
+ Update-MgApplication - ApplicationId $clientAadApplication .Id - RequiredResourceAccess $requiredResourcesAccess
391
386
Write-Host " Granted permissions."
392
387
393
388
394
389
395
390
# print the registered app portal URL for any further navigation
396
- Write-Host " Successfully registered and configured that app registration for 'msal-react-spa' at `n $clientPortalUrl " - ForegroundColor Green
391
+ Write-Host " Successfully registered and configured that app registration for 'msal-react-spa' at `n $clientPortalUrl " - ForegroundColor Red
397
392
398
393
# Update config file for 'service'
399
- # $configFile = $pwd.Path + "\..\API\config.js "
400
- $configFile = $ (Resolve-Path ($pwd.Path + " \..\API\config.js " ))
394
+ # $configFile = $pwd.Path + "\..\API\config.json "
395
+ $configFile = $ (Resolve-Path ($pwd.Path + " \..\API\config.json " ))
401
396
402
397
$dictionary = @ { " Enter_the_Application_Id_Here" = $serviceAadApplication.AppId ;" Enter_the_Tenant_Info_Here" = $tenantId };
403
398
404
- Write-Host " Updating the sample config '$configFile ' with the following config values:" - ForegroundColor Yellow
399
+ Write-Host " Updating the sample config '$configFile ' with the following config values:" - ForegroundColor Green
405
400
$dictionary
406
401
Write-Host " -----------------"
407
402
@@ -413,7 +408,7 @@ Function ConfigureApplications
413
408
414
409
$dictionary = @ { " Enter_the_Application_Id_Here" = $clientAadApplication.AppId ;" Enter_the_Tenant_Info_Here" = $tenantId ;" Enter_the_Web_Api_Application_Id_Here" = $serviceAadApplication.AppId };
415
410
416
- Write-Host " Updating the sample config '$configFile ' with the following config values:" - ForegroundColor Yellow
411
+ Write-Host " Updating the sample config '$configFile ' with the following config values:" - ForegroundColor Green
417
412
$dictionary
418
413
Write-Host " -----------------"
419
414
@@ -445,7 +440,7 @@ $ErrorActionPreference = "Stop"
445
440
446
441
try
447
442
{
448
- ConfigureApplications - tenantId $tenantId ls - environment $azureEnvironmentName
443
+ ConfigureApplications - tenantId $tenantId - environment $azureEnvironmentName
449
444
}
450
445
catch
451
446
{
0 commit comments