我已在Azure Active Directory中注册了一个应用程序作为通过客户端密钥进行身份验证的守护程序。我添加了Graph API权限,并已授予管理员同意以获取共享点列表,并且可以在c#中成功使用Graph API。我还授予了管理员对Mail.Send Graph API的同意,但拒绝访问。呼叫已正确设置,并且我用作“发件人”字段的电子邮件地址是管理员邮箱。我正在做一些其他配置还是错过配置?
致电进行身份验证
var clientSecret = @"{My generated Secret in Azure}";
var clientId = @"{My Client Id}";
var tenantID = @"{My Tenant Id}";
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.WithClientSecret(clientSecret)
.Build();
ClientCredentialProvider authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);
return new GraphServiceClient(authenticationProvider);
我的呼叫代码以发送电子邮件
var clientSecret = @"{My generated Secret in Azure}";
var clientId = @"{My Client Id}";
var tenantID = @"{My Tenant Id}";
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantID)
.WithClientSecret(clientSecret)
.Build();
ClientCredentialProvider authenticationProvider = new ClientCredentialProvider(confidentialClientApplication);
return new GraphServiceClient(authenticationProvider);