Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

active directory - 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

question from:https://stackoverflow.com/questions/65907049/how-to-create-azure-ad-b2c-identity-experience-framework-policy-key-where-name

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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"  
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...