【问题标题】:How to create / generate Bearer token with PowerShell?如何使用 PowerShell 创建/生成不记名令牌?
【发布时间】:2019-12-30 08:16:51
【问题描述】:

如何使用 PowerShell 创建/生成 Bearer 令牌? 我需要找到一种使用 PowerShell 生成不记名令牌的方法。

【问题讨论】:

    标签: azure-active-directory bearer-token


    【解决方案1】:
    $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
    
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-23
      • 1970-01-01
      • 2020-11-15
      • 2022-01-19
      • 2015-11-30
      • 2019-08-11
      • 2022-01-23
      • 2014-10-08
      相关资源
      最近更新 更多