Posts

Showing posts from May, 2018

Handle "Forgot your password" / "Reset password" in Azure B2C Activity Directory "SignInSignUp" policy

Image
When you use Azure B2C Activity Directory "SignInSignUp" policy in your application, then you will see below screen shot signin /signup pop up window. If you click on "Forgot your password?", and the login is failure at this code " await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, Authority) ;". You can catch this error and the error message should contains "AADB2C90118", and then you can handle this error to invoke "Reset Password Service" with following code:  AuthenticationResult authResult= await PublicClientApp.AcquireTokenAsync(Scopes, GetUserByPolicy(PublicClientApp.Users, PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, AuthorityResetPassword);    You can retrieve user name and "id_token" from "authResult" from above code. Refer to Azure B2C sample project " https://github.com