Search code examples
azureazure-active-directorymicrosoft-graph-apiazure-ad-msal

Get homepage URL of applications user has access to from Microsoft Azure AD via Microsoft Graph API?


My goal: get applications user has access to and their homepage URL's from Microsoft Azure AD graph API.

Using https://learn.microsoft.com/en-us/graph/api/resources/approleassignment I can see what applications the user is a user of (HTTP GET https://graph.microsoft.com/v1.0/me/appRoleAssignments). But the resulting data does not have the application ID, so I can't get the app details via the /applications/(appID) endpoint https://learn.microsoft.com/en-us/graph/api/application-get (HTTP GET https://graph.microsoft.com/v1.0/applications/).

How do I get the application details of applications the user (who is logged in) is a user of?

I queried the https://learn.microsoft.com/en-us/graph/api/resources/approleassignment endpoint then tried feeding it's data to the applications endpoint, and none of the ID values from the rolesassignment endpoint resulted in a successful request or matched with the numbers in the portal.azure.com page of the apps.

Edit: I see the resourceID matches the object ID in the azure portal now. But, when I do a query to graph.microsoft.com/v1.0/applications / {ObjectID} { "code": "Request_ResourceNotFound", "message": "Resource '{ObjectID}' does not exist or one of its queried reference-property objects are not present.", "innerError": { "date": "2023-07-12T14:36:44", "request-id": "", "client-request-id": "" } } I put the messages. Is my query right? Is this a permissions thing?


Solution

  • To get the application home page URL from app role assignments, it's going to be a multi-step procedure.

    First, get the resourceId property from the app role assignment. This is going to be the service principal id.

    Then you would need to get the details of the service principal using Get servicePrincipal operation. Look for appId property in the service principal details. This is the id of the application.

    Once you have the application id, you would then get the details of the application using Get application and from there you can get the home page URL.