Search code examples
azuregoazure-active-directory

How to get Object ID from Application (client) ID and Directory (tenant) ID?


Using the azure go sdk, is it possible to use the Application (client) ID, Directory (tenant) ID, and a valid Client secret to obtain the Object ID of the Azure Active Directory application? How?

Here is a screenshot of the Azure portal to help clarify those three fields.

enter image description here

I've tried to use the following function from graphrbac, but the *result.Value does not match with the Object ID from the screenshot above.

func (client ApplicationsClient) GetServicePrincipalsIDByAppID(ctx context.Context, applicationID string) (result ServicePrincipalObjectResult, err error)


Solution

  • The function in your question is to get the id of the service principal(located in the Enterprise applications in the portal), not the azure ad application(located in the App registrations) which in your screenshot.

    It seems there is no such function to get the objectid of the application via the properties that you want to use. (I am not familiar with go, if there is something wrong, please correct me.) The most similar is func (ApplicationsClient) Get which need the objectid, or the func (ApplicationsClient) List to list applications.