Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin is not running when authorizationUserAgent is equal to BROWSER or DEFAULT. #111

Open
jeimz143 opened this issue Oct 13, 2023 · 0 comments

Comments

@jeimz143
Copy link

jeimz143 commented Oct 13, 2023

Hi @wrobins , first of all as a student|newbie, i love your plugin and it really help me connect to my B2C project.

Currently i am having issue with the authorizationUserAgent field. If it is set to WEBVIEW, everything looks good but, if it was set to BROWSER or DEFAULT, nothing is happening like the Plugin is not running. i'm not sure if i'm missing some steps. currently, my project is running with Vue.js and capacitor JS 5.

The main reason why i needed to run the plugin via external BROWSER is that, Facebook login via Webview has been deprecated and it does not allow anymore to login via Webview it needs to be in browser.
https://developers.facebook.com/docs/facebook-login/android/deprecating-webviews/

here is my code:

setup() {
    onMounted(async () => {
      let msal = window.cordova.plugins.msalPlugin;
      const options = {
        clientId: "<MY_CLIENT_ID>",
        authorizationUserAgent: "BROWSER",
        accountMode: "SINGLE",
        authorities: [
          {
            type: "B2C",
            authorityUrl:
              "https://MYB2C.b2clogin.com/tfp/MYB2C.onmicrosoft.com/<MY-POLICY-SIGN-UP-SIGN-IN>",
            default: true,
          },
        ],
        scopes: [
          "MyApp.Read",
        ],
        authorizationQueryStringParameters: [
          {
            param: "domain_hint",
            value: "<MY-DOMAIN-HINT>",
          },
        ],
      };
      await msal.msalInit(
        function () {
          msal.signInSilent(
            function (resp) {
              // resp is an object containing information about the signed in user, see below.
              // saveAuth(resp);
              console.log(resp);
            },
            function (err) {
              // err probably says "No accounts found" but maybe other debugging info
              // Don't show this to the user; just use it for debugging.
              // Here's where you either call the next prompt or wait for the user
              console.log(err);
              msal.signInInteractive(
                function (resp) {
                  // resp is an object containing information about the signed in user, see below.
                  // saveAuth(resp);
                  console.log(resp);
                },
                (err) => console.log(err)
              );
            }
          );
        },
        function (err) {
          console.log(err);
        },
        options
      );
    });
    return {};
  }

Thanks in Advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant