iosreact-nativeoauth-2.0azure-ad-b2cappauth

Azure B2C User Flow doesn't return back to the mobile app in iOS


I am using the following package to integrate Azure B2C User flow in React Native Mobile App. https://www.npmjs.com/package/react-native-app-auth?activeTab=readme

On Android, the user flow works fine and I am able to receive the idtoken in the app.

In iOS , I am redirected to B2c policy , from there I select any IDP such as Google, I go to the IDP sing in , enter the credentials and then nothing happens.

I have done the Setup related steps mentioned in the package documentation. But I can feel that the authorize function never returns back to the app I neither get an error nor the token

try {
  console.log("before calling autorize");
  const result = await authorize(config);
  console.log("Result Object : ",result);
  const authToken = result.idToken;
  console.log("ID TOKEN : " , authToken);
  const decodedToken = jwt_decode(authToken);
  return decodedToken;
 
  
  // result includes accessToken, accessTokenExpirationDate and refreshToken
} catch (error) {
  console.log("Error occured");
  console.log(error);
}

I even tried to change to a custom policy with App insights integrated, but I could not find any errors or traces for the custom policy I will be grateful if I can get any pointers to resolve this issue.


Solution

  • I was able to resolve the issue. It was just a missing '/' at the end of the redirect uri for iOS I am now wondering why this is not mentioned anywhere in the docs. It is only mentioned as 'Important' at the end of the sample for AD.

    https://github.com/FormidableLabs/react-native-app-auth/blob/main/docs/config-examples/azure-active-directory.md

    enter image description here

    For example in Azure App config if the redirect uri is com.bundleid://auth

    In the mobile app config it should be com.bundleid://auth/