I need to fetch all details of the user signin activities via Microsoft Graph lib.
I gave all the permission(maybe further more)
I can get all information about signin activity but just Authentication Details are missing.
Please see the picture which one I indicate
Here is my code block to obtain all signin logs
var scopes = new[] { "https://graph.microsoft.com/.default" };
var tenantId = "aaaaaa-bbbb-cccc-dddd-fffffff";
var clientId = "kkkkkkkk-zzzz-yyyy-xxxxx-ghhhhhhh";
var clientSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var tenantName = "example.com";
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
var clientSecretCredential = new ClientSecretCredential(tenantId, clientId, clientSecret, options);
var totalList = new List<Microsoft.Graph.Models.SignIn>();
GraphServiceClient graphClient = new GraphServiceClient(clientSecretCredential, scopes);
var signIns = await graphClient.AuditLogs.SignIns.GetAsync();
var aulogs= await graphClient.AuditLogs.GetAsync();
How can I also obtain the Authentication Details ?
SignIn class has no such as Property.
2
Answers
Let‘s see the properties for the V1.0 List signin Graph API, there’s no Authentication Details property indeed, so that we don’t get it in the response should be the expected behavior.
As a workaround, we might use the beta version API which containing the Authentication Details priperty. But APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. We’d better to continue to use the V1.0 version if possible.
Using Beta version Graph SDK requires us to use
Microsoft.Graph.Beta
package instead ofMicrosoft.Graph
. Requires to pick the "Include prerelease" option.But this API requires Microsoft Entra ID P1 or P2 license so that I can’t test for your..
Posting details proof of work @Tiny Wang,
In v1.0 version of Microsoft Graph API,
authenticationDetails
property is not available in the response but it is available in beta version of Microsoft Graph API However, APIs in the /beta version of Microsoft Graph are still being developed and mostly not recommendable. It’s best to stick with the v1.0 version for production.For using Microsoft Graph API
Beta
version need to have Microsoft Entra ID P1 or P2 licenses.Initially, I registered Microsoft Entra application, granted and consented Application type API Permissions
AuditLog.Read.All
andDirectory.Read.All
:Make use of below C# code, To fetch SignIndetail for all users with property authenticationDetails:
Output:
The maximum and default size is 1000 objects and by default the most recent signIns are returned first.
Reference:
Get signIn – Microsoft Graph beta | Microsoft Learn