【问题标题】:Add guest invitation via Microsoft Graph and App Credentials give Method Not Found通过 Microsoft Graph 和 App Credentials 添加来宾邀请给 Method Not Found
【发布时间】:2020-10-11 21:42:37
【问题描述】:

我正在尝试开发一个类似于 question 中所要求的应用程序

我已在 Azure 门户中为应用配置了适当的权限,并按照指南 here 操作。

应用程序似乎正在使用范围 https://graph.microsoft.com/.default 从 AD 获取正确的令牌

调用后,它会以“未找到方法”错误响应。

Code: UnknownError
Message: Method not allowed
Inner error:
    AdditionalData:
    date: 2020-10-11T21:36:03
    request-id: ...
    client-request-id: ...
ClientRequestId: ...

request-id、client-request-id 和 ClientRequestId 都具有相同的值。

有没有办法解决返回的 ID 出现此错误的原因? 我的配置中是否缺少某些内容?

此应用程序的目的是为我们举办的 Give Camp 自助注册志愿者,并将使用 Microsoft Teams 作为协作工具。如果有更好的方法可以做到这一点,我愿意接受建议。

代码可以在这里找到https://github.com/swogc/GiveCamp-Teams

为应用授予的权限:

【问题讨论】:

  • 确保在您的应用注册中,您已配置 API 权限并单击按钮以授予管理员许可。
  • 您能分享一下您的 HTTP 请求网址吗?创建邀请需要使用POST。正如 Jason 所说,权限也可能需要授予管理员同意。
  • @PamelaPeng - 这是使用 Microsoft Graph 库,所以我假设它正在发布一个帖子。 Ref Line
  • @JasonP 我相信我配置了正确的权限。我用权限截图更新了帖子

标签: azure azure-active-directory microsoft-graph-api microsoft-teams


【解决方案1】:

似乎权限和帖子都可以。如果应用是无用户授权的,可以参考here,使用Client credentials provider调用MS图API。

string[] scopes = { "https://graph.microsoft.com/.default" };

IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                            .Create(clientId)
                            .WithTenantId(tenantID)
                            .WithClientSecret(clientSecret)
                            .Build();

ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication, scopes);

GraphServiceClient graphClient = new GraphServiceClient(authProvider);

var invitation = new Invitation
{
    InvitedUserEmailAddress = "pamela@xxx",
    InviteRedirectUrl = "https://southwestohiogivecamp.org",
    
};

await graphClient.Invitations.Request().AddAsync(invitation);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 2022-01-09
    • 1970-01-01
    相关资源
    最近更新 更多