Azure B2C自定义策略:无效请求,客户端机密错误

时间:2017-10-31 21:24:45

标签: azure azure-ad-b2c

我有一个Azure B2C自定义策略来注册。当我尝试获取刷新令牌时,我收到此错误:

{"error":"invalid_request","error_description":"AADB2C90079: Clients must send a client_secret when redeeming a confidential grant.\r\nCorrelation ID: 776e4226-467b-4648-b7f7-a9c09715fd68\r\nTimestamp: 2017-10-31 21:12:56Z\r\n"}

我正在使用此网址登录:

https://login.microsoftonline.com/<MyTenant>.onmicrosoft.com/oauth2/authorize?
p=B2C_1A_signup_signin
&client_id=<MyB2CAppID>
&nonce=defaultNonce
&redirect_uri=http%3A%2F%2Flocalhost%3A4200
&scope=openid+offline_access
&response_type=code
&prompt=login

使用从前一个网址获取的代码,我尝试使用此网址获取访问令牌:

https://login.<MyTenant>.com/exob2ctest.onmicrosoft.com/oauth2/v2.0/token?
p=B2C_1A_signup_signin
&grant_type=authorization_code
&client_id=<MyB2CAppID>
&redirect_uri=urn:ietf:wg:oauth:2.0:oo
&code=<MyCode>
&scope=openid%20offline_access
&client_secret=<MyB2CAppSecret>

之后我收到错误。 我在client_secret参数上使用在client_id中引用的B2C应用程序上生成的密钥。 当我使用内置策略尝试此操作时,我得到刷新令牌没有问题。可能是我的自定义政策中缺少的内容吗?

提前致谢!

1 个答案:

答案 0 :(得分:2)

您需要将您的请求作为POST请求发送到/token端点,其中policy参数作为查询字符串参数,其余部分位于x-www-form-urlencoded正文中。