@@ -289,28 +289,30 @@ Function ConfigureApplications
289
289
# rename the user_impersonation scope if it exists to match the readme steps or add a new scope
290
290
$scopes = New-Object System.Collections.Generic.List[Microsoft.Open.AzureAD.Model.OAuth2Permission ]
291
291
292
- if ($scopes.Count -ge 0 )
292
+ # delete default scope i.e. User_impersonation
293
+ $scope = $serviceAadApplication.Oauth2Permissions | Where-Object { $_.Value -eq " User_impersonation" }
294
+ if ($scope -ne $null )
293
295
{
294
- # add all existing scopes first
295
- $serviceAadApplication.Oauth2Permissions | foreach-object { $scopes.Add ($_ ) }
296
-
297
- $scope = $serviceAadApplication.Oauth2Permissions | Where-Object { $_.Value -eq " User_impersonation" }
296
+ # disable the scope
297
+ $scope.IsEnabled = $false
298
+ $scopes.Add ($scope )
299
+ Set-AzureADApplication - ObjectId $serviceAadApplication.ObjectId - Oauth2Permissions $scopes
300
+
301
+ # clear the scope
302
+ $scopes.Clear ()
303
+ Set-AzureADApplication - ObjectId $serviceAadApplication.ObjectId - Oauth2Permissions $scopes
304
+ }
298
305
299
- if ($scope -ne $null )
300
- {
301
- $scope.Value = " access_as_user"
302
- }
303
- else
304
- {
305
- # Add scope
306
- $scope = CreateScope - value " access_as_user" `
306
+ if ($scopes.Count -ge 0 )
307
+ {
308
+ $scope = CreateScope - value access_as_user `
307
309
- userConsentDisplayName " Access ProfileAPI" `
308
310
- userConsentDescription " Allow the application to access ProfileAPI on your behalf." `
309
311
- adminConsentDisplayName " Access ProfileAPI" `
310
312
- adminConsentDescription " Allows the app to have the same access to information in the directory on behalf of the signed-in user."
311
313
312
- $scopes.Add ($scope )
313
- }
314
+ $scopes.Add ($scope )
315
+
314
316
}
315
317
316
318
# add/update scopes
@@ -396,13 +398,13 @@ Function ConfigureApplications
396
398
# Update config file for 'service'
397
399
$configFile = $pwd.Path + " \..\ProfileAPI\appsettings.json"
398
400
Write-Host " Updating the sample code ($configFile )"
399
- $dictionary = @ { " Domain" = $tenantName ;" ClientId" = $serviceAadApplication.AppId ;" ClientSecret" = $serviceAppKey };
401
+ $dictionary = @ { " Domain" = $tenantName ;" ClientId" = $serviceAadApplication.AppId ;" ClientSecret" = $serviceAppKey ; " TenantId " = $tenantId };
400
402
UpdateTextFile - configFilePath $configFile - dictionary $dictionary
401
403
402
404
# Update config file for 'client'
403
405
$configFile = $pwd.Path + " \..\ProfileSPA\src\utils\authConfig.js"
404
406
Write-Host " Updating the sample code ($configFile )"
405
- $dictionary = @ { " Enter the Client Id (aka 'Application ID') " = $clientAadApplication.AppId ;" Enter the API scopes as declared in the app registration 'Expose an Api' blade in the form of 'api://{client_id}/.default' " = ( " api:// " + $serviceAadApplication.AppId + " /access_as_user " ) };
407
+ $dictionary = @ { " Enter_the_Application_Id_Here " = $clientAadApplication.AppId ;" Enter_the_Tenant_Info_Here " = $tenantId ; " Enter_the_Application_Id_of_Service_Here " = $serviceAadApplication.AppId };
406
408
ReplaceInTextFile - configFilePath $configFile - dictionary $dictionary
407
409
Write-Host " "
408
410
Write-Host - ForegroundColor Green " ------------------------------------------------------------------------------------------------"
@@ -416,7 +418,13 @@ Function ConfigureApplications
416
418
Write-Host " - Navigate to the Manifest page and set the value 'replyUrlsWithType' as 'Spa'." - ForegroundColor Red
417
419
418
420
Write-Host - ForegroundColor Green " ------------------------------------------------------------------------------------------------"
419
-
421
+ if ($isOpenSSL -eq ' Y' )
422
+ {
423
+ Write-Host - ForegroundColor Green " ------------------------------------------------------------------------------------------------"
424
+ Write-Host " You have generated certificate using OpenSSL so follow below steps: "
425
+ Write-Host " Install the certificate on your system from current folder."
426
+ Write-Host - ForegroundColor Green " ------------------------------------------------------------------------------------------------"
427
+ }
420
428
Add-Content - Value " </tbody></table></body></html>" - Path createdApps.html
421
429
}
422
430
0 commit comments