How to fetch the "authentication" property of a User in the MSGraph API?

Thomas Balthazar 0 Reputation points
2024-07-02T12:25:15.4+00:00

Hi,

Using the Graph Explorer, I try to fetch the "authentication" property of a user, but I always get an empty result:

https://graph.microsoft.com/v1.0/me?$select=userPrincipalName,onPremisesUserPrincipalName,authentication

returns:

{     "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(userPrincipalName,onPremisesUserPrincipalName,authentication)/$entity",     "userPrincipalName": "<redacted>",     "onPremisesUserPrincipalName": "
<redacted>
" }

If I add "&$expand=authentication" at the end of the URL, I get this error:

{
    "error": {
        "code": "UnknownError",
        "message": "{\"ErrorCode\":\"badRequest\",\"Message\":\"Resource not found for segment 'users('redacted')'.\",\"Target\":null,\"Details\":null,\"InnerError\":null,\"InstanceAnnotations\":[],\"TypeAnnotation\":null}",
        "innerError": {
            "date": "2024-07-02T11:58:47",
            "request-id": "5417b491-c30a-4c4b-8875-dd26aac48652",
            "client-request-id": "3bcfde08-8c2b-e491-d48a-9dc3fc195dbe"
        }
    }
}

which is kind of expected since the documentation doesn't list the "authorization" as "expandable": https://learn.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0#relationships

But then, why does the "authentication" always returns an empty value. Is this a bug in the API or am I missing something?

The app I use to query the API has "User.Read.All" and "UserAuthenticationMethod.Read.All", it always gets an empty "authentication" property when trying to list users. But getting "https://graph.microsoft.com/v1.0/me/authentication/methods" returns a list of authentication methods.

Any idea?

Thanks!

t.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 120K Reputation points MVP Volunteer Moderator
    2024-07-02T16:17:59.0133333+00:00

    Use the /authentication/methods endpoint instead.

    GET https://graph.microsoft.com/beta/me/authentication/methods
    
    0 comments No comments

  2. Saddam Hussain Ansari 0 Reputation points
    2025-03-21T12:17:14.6166667+00:00

    Delete https://graph.microsoft.com/beta/users/userprincipalname/authentication/methods always give below error even tough SPN have required permissions.

    error

    {
        "error": {
            "code": "UnknownError",
            "message": "{\"ErrorCode\":\"badRequest\",\"Message\":\"Resource not found for segment 'users('******@growwearn.in')/authentication/microsoftAuthenticatorMethods'.\",\"Target\":null,\"Details\":null,\"InnerError\":null,\"InstanceAnnotations\":[],\"TypeAnnotation\":null}",
            "innerError": {
                "date": "2025-03-21T12:07:46",
                "request-id": "fad2a0cb-d124-427f-ad4a-7608c2fde2c3",
                "client-request-id": "10697aca-1906-4180-9059-25f0881de7d0"
            }
        }
    }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.