How to generate forgotPassword link dynamically

Javier Monleon Lopez 21 Reputation points
2022-12-28T08:32:58.98+00:00

Hello,
I have a signin-signup user flow within an AAD B2C in where users are added manually into the AAD directory by the owner through an invitation.

First time those users want to login the B2C directory, under the hood, they are forced to set their own password through the forgotPassword link. In there, they are prompted to introduce their email for receiving a code, which will be used to set the new password.

Currently, that link is provided by the "Forgot your password?" link of the Azure's login template.

Since the users are added manually to the AAD by the owner through an invitation, what I need is to generate the forgotPassword link through an api request or similar in order to let the owner sending it via a third party email along with the invitation, instead doing it through the template.

I tried to copy the url but when I open it in another browser I receive "bad request".

Any suggestion?

Thanks in advance.
JM

Azure Active Directory External Identities
No comments
{count} votes

Accepted answer
  1. Shweta Mathur 11,166 Reputation points Microsoft Employee
    2022-12-29T07:21:35.69+00:00

    Hi @Javier Monleon Lopez ,

    Thanks for reaching out.

    I understand you are manually creating the users in B2C and looking to send the forgot Password link separately via email along with the invitation.

    The link you are trying to copy is in continuation of Sign In policy where clicking on "Forgot password" redirects the user automatically to password reset page.

    To send the password link separately, you can create the new user flow "Password Reset" to reset the password.

    274732-image.png

    and send the below URL along with invitation to update the password directly

    https://<tenant>.b2clogin.com/<tenant>.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_pwdReset&client_id=xxxx-xxx-xxx-xxx-xxx&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=id_token&prompt=login

    where B2C_1_pwdReset is password reset user flow policy.

    Users can directly reset the password with link provided in the email.

    274658-image.png

    Hope this will help.

    Thanks,
    Shweta

    ----------------------------------------------------

    Please remember to "Accept Answer" if answer helped you.

    No comments

1 additional answer

Sort by: Most helpful
  1. Javier Monleon Lopez 21 Reputation points
    2022-12-29T08:22:22.38+00:00

    It is exacly what I was lookin for.

    Thank you so much for your answer!

    No comments