Skip to content

How to create Azure AD app using service principal credentials #33

@akhilesh2410

Description

@akhilesh2410

I have created an Azure AD app using " az ad sp create-for-rbac --sdk-auth --role Owner" command.
Also i have given required api permission as mentioned below:
api-permission

I am getting 403 error with below code:
error i am getting
error": "graphrbac.ApplicationsClient#Create: Failure responding to request: StatusCode=403 -- Original Error: autorest/azure: Service returned an error. Status=403 Code=\"Unknown\" Message=\"Unknown service error\" Details=[{\"odata.error\":{\"code\":\"Authorization_RequestDenied\",\"date\":\"2021-12-23T11:41:23\",\"message\":{\"lang\":\"en\",\"value\":\"Insufficient privileges to complete the operation.\"},\"requestId\":\"f192ac37-8b05-4a81-a582-13f0f5ca3594\"}}]"

Code i am using to initialize app client is :

appClient := graphrbac.NewApplicationsClient(tenantID) credConfig := auth.NewClientCredentialsConfig(clientID, clientSecret, tenantID) //credConfig.Resource = azure.PublicCloud.ResourceIdentifiers.Graph credConfig.Resource = "https://graph.microsoft.com" authorizer, err := credConfig.Authorizer() if err != nil { return appClient, err } appClient.Authorizer = authorizer

I am not sure how i can create an Azure AD app client for microsoft Graph API SDK, since there is no method i have found for the same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions