Welcome to OGeek Q&A 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...