0

How to add authroized client applications (in portal : app registration -> Expose API -> add Authorized client applications) during app registration using powershell Azure CLI.

rnstvrcstll
  • 71
  • 1
  • 7
  • If the answer was helpful, Please [Accept it as an Answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work), so that others who encounter the same issue can find this solution and fix their problem. – Ansuman Bal Jan 28 '22 at 09:39

1 Answers1

1

There is no az command to directly add preauthorized clients to a app registration instead you will have to use Graph API (beta) to update the same from Graph Explorer or az rest command.

Get OauthPermissionId with az command :

az ad app show --id $appId --query "oauth2Permissions[].id"

I tested the same from Graph Explorer :

enter image description here

Ran Patch : https://graph.microsoft.com/beta/applications/<appObjectId>

With Request body as :

{
    "api": {
        "preAuthorizedApplications": [
            {
                "appId": "authorizedappClientID",
                "permissionIds": [
                    "oauth2PermissionId"
                ]
            }
        ]
    }
}

enter image description here

Output:

enter image description here

Reference for az rest can be fount in this SO thread answered by Joy Wang .

Ansuman Bal
  • 9,705
  • 2
  • 10
  • 27