Я борюсь с Microsft Graph. Я хочу получить вызовы команд из API графа, чтобы выбросить их в наше программное обеспечение для билетов. Звучит легко на первый взгляд. И я думаю, что это так, но я не понимаю, почему это не сработает.
Чтобы было ясно, я не хочу создавать приложение для команд, я просто хочу получать вызовы / встречи в группах.
Это мой код (удаленные идентификаторы по понятным причинам):
class Program
{
// (Company IDs)
static string tenantId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
static string servicePrincipal = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
static string servicePrincipalKey = "keyyyyy";
// Admin consent if not already applied
// https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/adminconsent?client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&state=randomState
// In my case admin consent was given via azure portal for the following permissions:
// Yes, it's too much. But I'm desperate...
/* Microsoft Graph (10)
CallRecords.Read.All
Calls.AccessMedia.All
ChannelMessage.Read.All
Chat.Read.All
IdentityProvider.Read.All
OnlineMeetings.Read.All
TeamsActivity.Read.All
TeamsApp.Read.All
User.Read.All
*/
static string[] scopes = {
"https://graph.microsoft.com/.default",
//"https://graph.microsoft.com/CallRecords.Read.All" // doesn't work
//"https://graph.microsoft.com/TeamsApp.Read.All" // doesn't work
//"https://graph.microsoft.com/Chat.ReadWrite.All" // doesn't work
};
static async Task Main(string[] args)
{
var authority = $"https://login.microsoftonline.com/" + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + "/v2.0";
var clientConf = ConfidentialClientApplicationBuilder
.Create(servicePrincipal)
.WithAuthority(authority, true)
.WithClientSecret(servicePrincipalKey)
.Build();
GraphServiceClient graphClient = new GraphServiceClient(new DelegateAuthenticationProvider(async(requestMessage) =>
{
var authResult = await clientConf
.AcquireTokenForClient(scopes)
.ExecuteAsync();
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authResult.AccessToken);
}));
//_ = graphClient.Teams.Request().GetAsync(); // Debug test
// Trying to fetch all calls or meetings
var onlineMeetings = await graphClient
.Communications.Calls.Request().GetAsync(); // Doesn't work
//.Users.Request().GetAsync(); // This works!
//.Communications.OnlineMeetings.Request().GetAsync(); // Doesn't work
Console.WriteLine(onlineMeetings);
// If requesting users, this works without issues
/*
var count = 0;
foreach (var user in onlineMeetings) {
Console.WriteLine(count);
Console.WriteLine(user.UserPrincipalName);
count++;
}
*/
}
}
Когда я запускаю этот беспорядок, я получаю следующую ошибку:
"Microsoft.Graph.ServiceException in System.Private.CoreLib.dll"
Code: UnknownError
{
"errorCode":"7503",
"message":"`**Application is not registered in our store.**`",
"instanceAnnotations":[]
}
Есть ли у кого-нибудь Понятие о том, что я тут делаю не так?
Stacktrace
ClientRequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
at Microsoft.Graph.HttpProvider.<SendAsync>d__18.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__35.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.BaseRequest.<SendAsync>d__31`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Graph.CloudCommunicationsCallsCollectionRequest.<GetAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Teams_Graph.Program.<Main>d__4.MoveNext() in c:\Users\<user.name>\Documents\Development\C#\Teams-Graph\Program.cs: Line50