0

I am trying to sign up the users using Azure B2C(by doing this I am using MSAL with Angular), by mail confirmation, captcha v2(google) and MFA.
For the first attempt I used just a normal sign up with the email and afterwards with MFA and had no issues creating the users.
Than I added captcha and in my sign-up, meaning that I needed to use a custom page.
To add captcha feature I used the following process from this link Link - Create Captcha with Azure B2C (regarding one step that is described in the article, the azure function was created in the portal, because locally I had some issues)
In my sign up page where you add the email address and all the claims of the user, after adding all the claims and checked the captcha feature, than press for create, appears the following message:

errorCode: "AADB2C90261" message: "The claims exchange 'PreUserWriteRestful' specified in step '1' returned HTTP error response that could not be parsed." status: "400"

AADB2C90261 -Taken from Microsoft page - Error Code - The claims exchange '{0}' specified in step '{1}' returned HTTP error response that could not be parsed.

Also the MFA feature doesn't appear. What can be ? that I missed to do ? Or what it represents ?
Tested without MFA and the same issue persists
Did anybody that is using Azure B2C added captcha ?

Thank you.

SilviuM
  • 79
  • 9
  • In your Azure function, have you modified any code in **[index.js](https://i.imgur.com/SPFO2yY.png)** file or left it default? – Sridevi Nov 02 '22 at 04:44
  • No I did not modify anything, I let it default, and as I stated this was done in the portal, because locally I cannot do it - function file [category](https://postimg.cc/2VV7S1sC) . Only difference that I am noticing that mine is using C sharp and the one presented by you is using js. I am gonna change the runtime stack to see if it works. Should be this a problem ? – SilviuM Nov 02 '22 at 08:43
  • Got the same error even with **js** like ***[this,](https://i.imgur.com/H5rLLdT.png)*** will try modifying few things and get back to you. – Sridevi Nov 02 '22 at 08:58
  • Same, I don't know where it is the issue, but thanks for being interested of the subject. – SilviuM Nov 02 '22 at 09:42

1 Answers1

2

I tried to reproduce the same in my environment and got below results:

Initially I deployed Azure Function via Portal and left index.js file as default like below:

enter image description here

I configured one API connector named Verify Captcha by adding above function URL in endpoint like below:

enter image description here

Now I added this API connector to my user flow like below:

enter image description here

When I ran the user flow by entering required details in Sign up page and checked the captcha feature, I got the same error as below:

enter image description here

To resolve the error, I tried deploying 2 Http Trigger Functions locally:

HttpTrigger1 - modified index.js file with this GitHub code and installed required modules like below:

enter image description here

HttpTrigger2 - left index.js file with default code like below:

enter image description here

By updating properties in local.settings.json file, I deployed these functions to Azure:

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"BASIC_AUTH_USERNAME": "xxxxx",
"BASIC_AUTH_PASSWORD": "xxxxx",
"CAPTCHA_SECRET_KEY": "6LfoQ9oxxxxx21BEE23-kPQkv6QIQt8",
"B2C_EXTENSIONS_APP_ID": "dcxxx0b0-d5xf-42x-b1a4-97xxx689x1"
}
}

Response:

enter image description here

When I checked in Azure Portal, functions are updated successfully like below:

enter image description here

I configured another API connector named Verify Captcha server side by adding above function URL in endpoint like below:

enter image description here

Now I updated API connector with above in my user flow like below:

enter image description here

I ran the user flow by entering required details in Sign up page and checked the captcha feature like below:

enter image description here

When I selected Create account, I got response like below:

enter image description here

It may take some time to complete the captcha like below:

enter image description here

When I tried the same with default index.js like HttpTrigger2, I'm getting same error as you. So, make sure to replace code in your index.js file with this GitHub code.

You can try the same in your environment locally to resolve the issue.

Sridevi
  • 10,599
  • 1
  • 4
  • 17
  • 1
    Thanks for the help. Honestly I don't how that function escaped from me, I thought that this should be default, but no. But to work I have to do it locally as you suggested than deploy it, with their azure function logic. If I do it only from the portal it won't work, even changing the azure function, probably will be needed more settings. I wanted to do it only from the portal because I cannot create app functions or group resources using vs code (I don't know why exactly, an error keeps appearing). But I created initially in the portal than created locally a function and deployed it after. – SilviuM Nov 09 '22 at 06:25
  • 1
    Now is appearing exactly how it's in the pictures set by you, but now seems there's another issue and is related more to the captcha by not seeing a complete check of the captcha. Still thank you for the help. – SilviuM Nov 09 '22 at 06:30