C# Microsoft图形异常:必须使用服务操作生成新密码凭据

C# Microsoft图形异常:必须使用服务操作生成新密码凭据,c#,.net-core,microsoft-graph-api,microsoft-graph-sdks,C#,.net Core,Microsoft Graph Api,Microsoft Graph Sdks,在创建应用程序时,如何使用Microsoft Graph Client SDK添加客户端机密 定义下面这样的应用程序失败,必须使用服务操作生成新密码凭据。例外情况: var应用程序新应用程序 { DisplayName=“我的应用程序名”, PasswordCredentials=新列表 { 新密码凭证 { SecretText=secretKey, DisplayName=“默认机密”, EndDateTime=DateTimeOffset.MaxValue, KeyId=Guid.NewGu

在创建应用程序时,如何使用Microsoft Graph Client SDK添加客户端机密

定义下面这样的应用程序失败,必须使用服务操作生成新密码凭据。例外情况:

var应用程序新应用程序
{
DisplayName=“我的应用程序名”,
PasswordCredentials=新列表
{
新密码凭证
{
SecretText=secretKey,
DisplayName=“默认机密”,
EndDateTime=DateTimeOffset.MaxValue,
KeyId=Guid.NewGuid(),
StartDateTime=DateTimeOffset。现在,
CustomKeyIdentifier=null,
提示=secretKey.Substring(4)
}
}
};
等待graphClient.Applications.Request().AddAsync(应用程序);

我已经找到了有关如何使用HTTPPOST实现这一点的信息,但在使用Microsoft Graph client SDK时没有找到这些信息。

找到了它,只是需要更仔细地查看

var createdApplication=wait-graphClient.Applications.Request().AddAsync(应用程序);
var passwordCredential=新密码凭据
{
DisplayName=“密码友好名称”,
EndDateTime=DateTimeOffset.Parse(“31/12/2299”),//据我所知允许的最大值
KeyId=Guid.NewGuid(),
StartDateTime=DateTimeOffset。现在,
CustomKeyIdentifier=null,
};
var passwordCredential=wait graphClient.Applications[createdApplication.Id]
.AddPassword(密码凭证)
.Request()
.PostAsync();

返回值
passwordCredential
保存秘密文本。

找到它,只需在数据库中更仔细地查找

var createdApplication=wait-graphClient.Applications.Request().AddAsync(应用程序);
var passwordCredential=新密码凭据
{
DisplayName=“密码友好名称”,
EndDateTime=DateTimeOffset.Parse(“31/12/2299”),//据我所知允许的最大值
KeyId=Guid.NewGuid(),
StartDateTime=DateTimeOffset。现在,
CustomKeyIdentifier=null,
};
var passwordCredential=wait graphClient.Applications[createdApplication.Id]
.AddPassword(密码凭证)
.Request()
.PostAsync();

返回值
passwordCredential
保存秘密文本。

您不能将passwordCredentials:[]直接添加到应用程序创建后调用。您将得到与此类似的错误:必须使用服务操作生成新密码凭据。您必须首先创建应用程序,然后进行POST调用以更新应用程序的passwordCredentials字段。通过此更改,您无法再生成自己的密文。您只能设置开始日期、结束日期和显示名称


参考:

您不能将密码凭据:[]直接添加到应用程序创建后调用。您将得到与此类似的错误:必须使用服务操作生成新密码凭据。您必须首先创建应用程序,然后进行POST调用以更新应用程序的passwordCredentials字段。通过此更改,您无法再生成自己的密文。您只能设置开始日期、结束日期和显示名称

参考: