Hi, i am working with graph API for teams and new to the graph API. I need to get user presence. The API is working fine with graph Explorer by using the following endpoint https://graph.microsoft.com/v1.0/me/presence
I am using this end point in my windows application (C# .net Core). I am creating class library and added Graph SDK 5.17.0 .
I have given the delegated Permission Presence.Read and Presence.Read.All from organization account.
- I am trying with client secret by using tenantId, clientId, clientSecret
- It throws an error like 'Forbidden'
- I am trying with the following
Using Azure.Identity;
Using Microsoft.Graph;
var tenantId = "MytenantId";
var clientId = "MyclientId";
// using Azure.Identity;
var options = new UsernamePasswordCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud,
};
//var scopes = new[] { "https://graph.microsoft.com/.default" };
var scopes = new[] { "Presence.Read" };
var userName = "******@mail.com";
var password = "Password1!";
var userNamePasswordCredential = new UsernamePasswordCredential(
userName, password, tenantId, clientId, options);
var graphClient = new GraphServiceClient(userNamePasswordCredential, scopes);
var mypresence = await graphClient.Me.Presence.GetAsync();
It's not returning the presence.