1

I was integrating azure adb2c on my native android app using MSAL. Currently I'm using createSingleAccountPublicClientApplication for my application. I have created sign-up and sign-in user flow and integrated with my application which is working perfectly. When the application is launched, it redirects to the Web view ,since I have mentioned the BrowserTabActivity inside the manifest file. But as per our requirement, we have to create our own custom webview and show all the userflows and get the callback as necessary . Is it possible to create custom webview for android and show the userflows?

Second issue is, When user taps on back button from SignUp Page , error code AADB2C90091 is thrown, not going back to signIn UserFlow Page . How can I show the signIn UserFlow Pag on back pressed?

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.microsoft_azure);
        context = MicrosoftAzureActivity.this;
        initializeUI();

        // Creates a PublicClientApplication object with res/raw/auth_config_single_account.json
        PublicClientApplication.createSingleAccountPublicClientApplication(MicrosoftAzureActivity.this,
                R.raw.auth_config_single_account,
                new IPublicClientApplication.ISingleAccountApplicationCreatedListener() {
                    @Override
                    public void onCreated(ISingleAccountPublicClientApplication application) {
                        /**
                         * This test app assumes that the app is only going to support one account.
                         * This requires "account_mode" : "SINGLE" in the config json file.
                         **/
                        mSingleAccountApp = application;

                        loadAccount();
                    }

                    @Override
                    public void onError(MsalException exception) {
                        displayError(exception);
                    }
                });

    }

loadAccount::

 private void loadAccount() {
        if (mSingleAccountApp == null) {

            return;
        }
         mSingleAccountApp.getCurrentAccountAsync(new ISingleAccountPublicClientApplication.CurrentAccountCallback() {
            @Override
            public void onAccountLoaded(@Nullable IAccount activeAccount) {
                // You can use the account data to update your UI or your app database.
                mAccount = activeAccount;
                if (activeAccount != null) {
              mSingleAccountApp.acquireTokenSilentAsync(getScopes(), B2CConfiguration.getAuthorityFromPolicyName("B2C_1_SignInSignUp"), getAuthSilentCallback());

                }
            }

            @Override
            public void onAccountChanged(@Nullable IAccount priorAccount, @Nullable IAccount currentAccount) {
                if (currentAccount == null) {
                    // Perform a cleanup task as the signed-in account changed.
                    showToastOnSignOut();
                }
            }

            @Override
            public void onError(@NonNull MsalException exception) {
                displayError(exception);
            }
        });
    }

auth_config_single_account::

{
  "client_id" : "cfsttrtkg-4545-fsrdh-822d-53453423-0",
  "redirect_uri" : "msauth://**********/***********,
  "account_mode" : "SINGLE",
  "broker_redirect_uri_registered": false,
  "authorization_user_agent" : "WEBVIEW",
  "authorities": [
    {
      "type": "B2C",
      "authority_url": "SIGNIN_SIGNUP_POLICY",
      "default": true
    },
    {
      "type": "B2C",
      "authority_url": "PASSWORD_RESET_POLICY"
    }
  ]
}
sooraj
  • 41
  • 2
  • 8

0 Answers0