Azure AD OAuth Login does not work in standalone APK build

72 views Asked by At

In my Expo app, I authenticate users by logging in with a Microsoft account, using the azure-ad-graph-expo package, which uses expo-auth-session.

It works perfectly in development, but for some reason, when I press the button to redirect the user to the login page in my APK Build, created with EAS, nothing happens.

Is there anything I need to change for this to work in standalone builds specifically ?

My props for authentication:

export const azureAdAppProps = {
  clientId        :   `${config.CLIENT_ID}`,
  tenantId        :   `${config.TENANT_ID}`,
  scope           :   'user.read',
  redirectUrl     :   AuthSession.makeRedirectUri({ path: "auth"}),
  returnUrl       :   "msauth.com.myapp://auth",
  clientSecret    :   `${config.CLIENT_SECRET}`,
  domainHint      :   'login.microsoftonline.com',
  prompt          :   'login'
};

Part of my login function:

  const handleAzureLogin = async () => {
    getToken();
    let login;
    try {
      login = await openAuthSession(azureAdAppProps);
      setResultData({ login });
      // Storing user data in AsyncStorage
      await AsyncStorage.setItem("@LoggedInUser", JSON.stringify(login));
    } catch (e) {

My app.json:

{
  "expo": {
    "name": "MyApp-V2",
    "slug": "MyApp-V2",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./src/assets/images/MyAppIcon.png",
    "scheme": "msauth.com.myapp",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./src/assets/images/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.myapp",
      "infoPlist": {
        "NSFaceIDUsageDescription": "Face ID é usado para autenticar o usuário."
      }
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./src/assets/images/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "msauth.com.myapp"
    },
    "web": {
      "favicon": "./src/assets/images/favicon.png"
    },

I found this related thread but it did not solve my issue.

0

There are 0 answers