pnp m365 cli 脚本尝试使用自定义应用程序注册登录时失败

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

我需要使用 pnp m365 cli 在 AAD 中添加/删除用户。

所以我想做这样的事情:

 m365 aad user add --userName "[email protected]"
 m365 aad user remove --userName "[email protected]"
 m365 aad user recyclebinitem restore --userName "[email protected]"

我已尝试按照此处的说明进行操作: https://pnp.github.io/cli-microsoft365/user-guide/using-own-identity/#login-and-consent

创建了一个新的应用程序注册,如下所示:

这就是我目前拥有的 API 权限:

我在一个像这样创建的 docker 容器中运行:

FROM m365pnp/cli-microsoft365:latest
ENV CLIMICROSOFT365_AADAPPID="clientIDFormyCustomApp"
ENV OFFICE365CLI_TENANT="mytenantId"

在容器内,到目前为止,我有一个只有一行的 powershell 脚本:

m365 登录 --authType secret --secret $applicationsecret

当我尝试运行它时,出现以下错误:

PS /workspaces/IntegrationTesting> ./createUser.ps1
Error: unauthorized_client: 700016 - [2023-04-10 20:52:24Z]: AADSTS700016: Application with identifier 'myapplicationid' was not found in the directory 'Microsoft'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant.

到目前为止我尝试了什么:

我检查以确保环境变量设置正确......它们是。
从 bash 终端运行“env”,我可以看到它们已设置。 我还检查了 docker env,它们也已设置。 我确保秘密也是正确的价值。事实上,我创造了一个新的秘密。

不确定还有什么要检查的。我是否拥有添加/删除 azure AD 用户的正确 API 权限?

azure docker powershell azure-active-directory azure-powershell
© www.soinside.com 2019 - 2024. All rights reserved.