我已经按照Microsoft在以下link中给出的代码示例进行操作,并且能够成功获取用户列表。
我在Azure Active Directory中注册的应用程序还具有“ OnlineMeeting.ReadWrite.All”应用程序权限。
但是,当我尝试通过在端点“ https://graph.microsoft.com/v1.0/me/onlineMeetings”中发布请求来拨打创建电话会议时。我收到403禁止错误。知道我为什么要得到这个吗?
答案 0 :(得分:2)
对于图api创建在线会议https://graph.microsoft.com/v1.0/me/onlineMeetings
,我们可以看到tutorial显示它不支持调用“应用程序许可”。它仅支持“委派权限”,因此我们只能通过密码授予流程而不是客户端凭据流程来请求它。
更新:
对于您要求创建在线会议的图形api的要求,我们可以只使用密码授予流程或授权代码流程。在此提供一个密码授予流(用户名和密码)示例,供您参考,使用该示例获取令牌并通过该令牌请求图形api。您也可以在此tutorial中找到此示例。
static async Task GetATokenForGraph()
{
string authority = "https://login.microsoftonline.com/contoso.com";
string[] scopes = new string[] { "user.read" };
IPublicClientApplication app;
app = PublicClientApplicationBuilder.Create(clientId)
.WithAuthority(authority)
.Build();
var accounts = await app.GetAccountsAsync();
AuthenticationResult result = null;
if (accounts.Any())
{
result = await app.AcquireTokenSilent(scopes, accounts.FirstOrDefault())
.ExecuteAsync();
}
else
{
try
{
var securePassword = new SecureString();
foreach (char c in "dummy") // you should fetch the password
securePassword.AppendChar(c); // keystroke by keystroke
result = await app.AcquireTokenByUsernamePassword(scopes,
"joe@contoso.com",
securePassword)
.ExecuteAsync();
}
catch(MsalException)
{
// See details below
}
}
Console.WriteLine(result.Account.Username);
}