Ashwin Agarkhed
Ashwin Agarkhed

Reputation: 77

How to create Azure AD B2C Identity Experience Framework policy key where name & secret are input params using powershell command

How to create Azure AD B2C Identity Experience Framework policy key where name & secret are input params using powershell command. I am not finding any source on internet for it

Upvotes: 2

Views: 1050

Answers (1)

unknown
unknown

Reputation: 7483

There doesn't seem to be a direct method to add policy key using powershell. All methods here.

You could use Microsoft Graph API with Powershell as a workaround. There is an article about connecting to Microsoft GraphAPI Using PowerShell.

Note: Add application permission TrustFrameworkKeySet.ReadWrite.All first, and grant consent for your tenant.

$Uri = "https://graph.microsoft.com/beta/trustFramework/keySets/{id}/generateKey"
    
$Body = @{
      use="sig"
      kty="RSA"
      nbf="1508969811"
      exp="1508969811"
    }

Invoke-RestMethod -Uri $Uri -Headers @{Authorization = "Bearer $($token)"} -Method Post -ContentType "application/json" -Body $Body

UPDATE:

The name of policy key is id of the trustframeworkKeySet.

Key type is kty of trustFrameworkKey. And secret is related to oct.

So, you need to create keySet first, then generate the key.

Create keySet:

POST https://graph.microsoft.com/beta/trustFramework/keySets
Content-type: application/json

{
  "id": "keyset1 like B2C_1A_test"  
}

Upvotes: 2

Related Questions