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 Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,416 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 100.1K Reputation points MVP
    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