azure - 使用访问令牌通过 Powershell 连接到 Exchange Online
问题描述
我从 Azure AD 获得了访问令牌和刷新令牌。我需要使用访问令牌/刷新令牌从 powershell 连接到各种 O365 服务。有人可以指导我如何继续在线连接到交换服务器。
有没有其他方法可以使用现代身份验证在线连接到交换服务器。我正在使用 ExchangeOnlineManagement 2.0.3 版本。我根据下面列出的博客的建议使用了下面的代码片段。我收到类似“密码长度超过 256”的错误。
我们需要自动化该过程,但无法使用访问令牌连接到交易所。
$AccessToken = <access-token-value>
$Authorization = "Bearer {0} " -f $AccessToken
$Password = ConvertTo-SecureString -AsPlainText $Authorization -Force
$UserCredential = New-Object System.Management.Automation.PSCredential("<upn-value>", $Password)
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true
错误消息:我收到密码长度超过 256 个字符的错误。
解决方案
抱歉耽搁了。
我理解你的要求。我知道使用New-PSSession
基本身份验证很快就会被弃用,因此您正在寻找替代方案。
但目前不支持使用访问令牌连接到 Exchange Online,因为AADSTS50052: The password entered exceeds the maximum length of '256'.
. 我不认为你需要担心它。届时,微软应该能够覆盖 V1 模块所具有的所有功能。
在这里看到一个类似的问题。
推荐阅读
- c# - C# JsonConvert - 如何解析不规则的键/值 JSON?
- swift - 如何在 Swift Playgrounds 中获得弹出对话框
- php - 如何合并jpeg图像
- javascript - 每次在 JavaScript 中调用函数时分别保存函数的结果
- html - 下拉菜单 css BEM 概念的 Html 标记
- powershell - PS Invoke-RestMethod:远程服务器返回错误:(500)内部服务器错误
- angular - NgStyle 未在可观察的完整回调中更新
- reactjs - 当前 url=link 到 react-router-dom 时如何将类添加到导航
- javascript - 防止<>将tinymce解析为>
- function - 如何实现异步调用堆栈