【发布时间】:2019-12-30 08:16:51
【问题描述】:
如何使用 PowerShell 创建/生成 Bearer 令牌? 我需要找到一种使用 PowerShell 生成不记名令牌的方法。
【问题讨论】:
标签: azure-active-directory bearer-token
如何使用 PowerShell 创建/生成 Bearer 令牌? 我需要找到一种使用 PowerShell 生成不记名令牌的方法。
【问题讨论】:
标签: azure-active-directory bearer-token
$ADAuthorityURL = "https://login.windows.net/common/oauth2/authorize/"
$resourceURL = "https://AQAEducation.onmicrosoft.com/<<AppRegistrion(1)>>"
$AADuserName = "your_user_name@xyz.onmicrosoft.com"
$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
【讨论】: