如何将 cmdlet Connect-PnPOnline 与选项、ClientId、ClientSecret 和 AADDomain 选项一起使用?

How to use the cmdlet Connect-PnPOnline with the options, ClientId, ClientSecret and AADDomain Options?

我正在尝试使用 command-let Connect-PnPOnline 和问题中描述的 3 个选项。

我的目标是在我的租户上创建一个 MS Team 团队,我想我需要连接到功能应用程序 (这将 运行 我的 PowerShell 脚本和图形 API 调用)来实现这个。


Microsoft 官方文档

这是this page pointing on this other page的第18个例子。

不幸的是,最后一个 link 包含很多过时的内容。


错误

我知道凭据是错误的,但我不知道为什么。

MSAL.Desktop.4.17.0.0.MsalServiceException: ErrorCode: invalid_client

Microsoft.Identity.Client.MsalServiceException: A configuration issue is preventing authentication - check the error message from the server for details.You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS7000215: Invalid client secret is provided. Trace ID: 31ee93b3-45b3-4058-9205-358e8e4da300 Correlation ID: 4b4c139d-e21b-4b0e-96b4-89f4068cefe3 Timestamp: 2020-08-13 16:54:54Z

StatusCode: 401 ResponseBody: {"error":"invalid_client","error_description":"AADSTS7000215: Invalid client secret is provided.\r\nTrace ID: 31ee93b3-45b3-4058-9205-358e8e4da300\r\nCorrelation ID: 4b4c139d-e21b-4b0e-96b4-89f4068cefe3\r\nTimestamp: 2020-08-13 16:54:54Z","error_codes":[7000215],"timestamp":"2020-08-13 16:54:54Z","trace_id":"31ee93b3-45b3-4058-9205-358e8e4da300","correlation_id":"4b4c139d-e21b-4b0e-96b4-89f4068cefe3","error_uri":"https://login.microsoftonline.com/error?code=7000215"} Headers: Pragma: no-cache

Strict-Transport-Security: max-age=31536000; includeSubDomains X-Content-Type-Options: nosniff client-request-id: 4b4c139d-e21b-4b0e-96b4-89f4068cefe3 x-ms-request-id: 31ee93b3-45b3-4058-9205-358e8e4da300 x-ms-ests-server: 2.1.10922.14 - DUB2 ProdSlices x-ms-clitelem: 1,7000215,0,, Cache-Control: no-store, no-cache P3P: CP="DSP CUR OTPi IND OTRi ONL FIN" Set-Cookie: fpc=Aulq_8y7IuJKshtSu9uJB4ocN4-WAQAAAF5nx9YOAAAA; expires=Sat, 12-Sep-2020 16:54:54 GMT; path=/; secure; HttpOnly; SameSite=None, x-ms-gateway-slice=prod; path=/; secure; HttpOnly, stsservicecookie=ests; path=/; secure; HttpOnly; SameSite=None Date: Thu, 13 Aug 2020 16:54:54 GMT


版本

PowerShell:5.1.18362.752

SharePointPnPPowerShellOnline:3.24.2008.0

AzureAD:2.0.2.106

蔚蓝:5.1.2

微软团队:1.1.4

您输入了错误的客户端密码。

Azure Active Directory -> App registrations -> yourregistrationApp,添加客户端密码:

  • 从应用 概述 页面,select 证书和机密 部分。
  • Select 新客户端密码.
  • 为您的客户端密码添加说明。
  • Select 持续时间。
  • Select 添加.

保存配置更改后,right-most 列将包含客户端密码值。 请务必复制值 以便在您的客户端应用程序代码中使用,因为一旦您离开此页面就无法访问它。