如何使用PowerShell创建/生成Bearer令牌?

问题描述 投票:0回答:1

如何使用PowerShell创建/生成Bearer令牌?我需要找出一种使用PowerShell生成承载令牌的方法。

azure-active-directory bearer-token
1个回答
0
投票
$ADAuthorityURL = "https://login.windows.net/common/oauth2/authorize/"
$resourceURL = "https://AQAEducation.onmicrosoft.com/<<AppRegistrion(1)>>"
$AADuserName = "[email protected]"
$AADpassword = "<<PASSWORD>>"
$AADClientID="<<Application Id of AppRegistrion(1)>>"
Write-Host "Retrieving the AAD Credentials...";

$credential = New-Object UserPasswordCredential($AADuserName, $AADpassword);
$authenticationContext = New-Object AuthenticationContext($ADAuthorityURL);
$authenticationResult = [AuthenticationContextIntegratedAuthExtensions]::AcquireTokenAsync($authenticationContext, $resourceURL, $AADClientID, $credential).Result;

$authenticationResult.AccessToken


© www.soinside.com 2019 - 2024. All rights reserved.