在 Azure 门户中,我可以为 Graph API 创建应用程序、密钥和权限。
我可以使用以下方式获取令牌:
AuthenticationContext ac = new AuthenticationContext("https://login.windows.net/graphDir1.onmicrosoft.com");
ClientCredential cc = new ClientCredential("b3b1fc59-84b8-4400-a715-ea8a7e40f4fe", "FStnXT1QON84B5o38aEmFdlNhEnYtzJ91Gg/JH/Jxiw=");
AuthenticationResult authResult = ac.AcquireToken("https://graph.windows.net", cc);
使用适用于 Windows PowerShell 的 Azure Active Directory 模块,我可以创建一个新的对称密钥。
New-MsolServicePrincipalCredential -AppPrincipalId ??? -Type Symmetric
在上面的代码中使用从 this 返回的键会返回错误:
AdalServiceException: AADSTS70002: Error validating credentials. AADSTS50012: Invalid client secret is provided.
这曾经与以前版本的 ADAL 一起使用,而不是ClientCredential
,SymmetricKeyCredential
但该类不再存在。
有没有办法从 PowerShell 生成与上述代码一起使用的密钥?