【问题标题】:Is there a way to connect to New-CsOnlineSession using an oauth token?有没有办法使用 oauth 令牌连接到 New-CsOnlineSession?
【发布时间】:2020-01-13 19:05:45
【问题描述】:

我正在寻找一种可以使用 oauth 令牌从网络应用程序运行“New-CsOnlineSession”的方法。 WebApp 将负责对用户进行身份验证。这将使用 Microsoft 现代身份验证,它将处理两个因素身份验证和同意。

我已在 Azure 门户中注册了一个应用程序,并授予了Skype For Business Powershell Server Application 的用户模拟权限。

当我连接到使用 WebApp 获得的令牌时,我收到错误消息,指出使用了错误的受众。

以下是我的 powershell 会话的记录。一旦我在 powershell 中工作,我的想法是 WebApp 将执行 powershell 命令,因此在 PowerShell 提示输入凭据的情况下执行此操作的任何方式都将不起作用。

PS C:\WINDOWS\system32> $token = ConvertTo-SecureString -String $oauthtoken -AsPlainText -Force
PS C:\WINDOWS\system32> $session = New-CsOnlineSession -OAuthAccessToken $token -Verbose
VERBOSE: OAuthAccessToken is provided.
VERBOSE: Determining domain to administer
VERBOSE: AdminDomain = 'mydomain.onmicrosoft.com'
VERBOSE: Discovering PowerShell endpoint URI
VERBOSE: TargetUri = 'https://admin2e.online.lync.com/OcsPowershellOAuth'
VERBOSE: AuthUri = 'https://login.windows.net/common/oauth2/authorize', ClientId = 7716031e-6f8b-45a4-b82b-922b1af0fbb4
VERBOSE: Validating authentication token.
New-CsOnlineSession : OAuthAccessToken has invalid audience https://teamsconfigapi-int.trafficmanager.net, expected https://admin2e.online.lync.com/OcsPowershellOAuth.
At line:1 char:12
+ $session = New-CsOnlineSession -OAuthAccessToken $token -Verbose
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-CsOnlineSession

【问题讨论】:

  • 您能解释一下您是如何在 Azure 门户中注册应用程序并进行用户模拟的吗?我找不到像“user_impersonation”这样的权限?

标签: powershell oauth azure-active-directory skype-for-business lync


【解决方案1】:

您能否尝试将 -OverrideAccessTokenResourceUri 设置为指定的 URL。

【讨论】:

    猜你喜欢
    • 2020-03-02
    • 1970-01-01
    • 2021-11-06
    • 1970-01-01
    • 2019-10-13
    • 2021-03-27
    • 1970-01-01
    • 2023-02-10
    • 2015-06-07
    相关资源
    最近更新 更多