I am trying to add optional claims for an app registered on Azure AD. I was following Documentation but the changes are not reflecting on the app's manifest. Still it is showing null or empty array like the below image.
I tried to follow this SO Question also but no luck.
$idTokenClaim = @()
$idTokenClaim += @([PSCustomObject] @{
name = "upn"
source = $null
essential = "true"
additionalProperties = @()
})
$optionalClaims = @{
idToken = $idTokenClaim
accessToken = @()
saml2Token = @()
} | ConvertTo-Json -Compress | ConvertTo-Json
az ad app update --id $($application.appId)--optional-claims '$optionalClaims'"
The JSON output for the $optionalClaims is :
Did I miss anything? Any help would be appreciated.
As mentioned in this article, in order to update OptionalClaim
property, we need to use hash table information.
Below are the steps which needs to be followed:
{
"idToken": [
{
"additionalProperties": [],
"essential": false,
"name": "ctry",
"source": null
},
{
"additionalProperties": [],
"essential": false,
"name": "acct",
"source": null
},
{
"additionalProperties": [],
"essential": false,
"name": "given_name",
"source": null
}
],
"accessToken": [],
"saml2Token": [
{
"additionalProperties": [],
"essential": false,
"name": "upn",
"source": null
}
]
}
Get-Content <pathofAboveJsonFile> | ConvertFrom-Json -AsHashtable
update-AzADApplication
to update the optionalClaim for an application in AzureAD. Update-AzADApplication -objectid <objectidoftheapplication> -optionalclaim $hastable