PeterStaev / nativescript-azure-mobile-apps

:cloud: NativeScript plugin for working with Microsoft Azure Mobile Apps services
Apache License 2.0
30 stars 10 forks source link

User Authentication: Unable to login on Android - No static method addCallback #41

Open nmandyam opened 3 years ago

nmandyam commented 3 years ago

I'm using this plugin to authenticate my Android app with Azure AD. I have set up an app on the Azure side, as needed. On login, though, I'm getting this error: Error Logging in! Error: java.lang.NoSuchMethodError: No static method addCallback(Lcom/google/common/util/concurrent/ListenableFuture;Lcom/google/common/util/concurrent/FutureCallback;)V in class Lcom/google/common/util/concurrent/Futures; or its super classes (declaration of 'com.google.common.util.concurrent.Futures' appears in /data/app/<app info>==/base.apk)

In terms of behaviour: when I click the button that should send me to Azure AD Auth, a pop-up comes up with nothing on it, then disappears.

As background: I have been unable to add the ALLOWED EXTERNAL REDIRECT URLS, since I can't find that specific setting in my Azure AD portal. The screen-shot that the README.md links to just does not exist in my login. There IS a way to add a Redirect URL for an Android app, but that URL is generated automatically by the portal (App name > Authentication > Android > Add URI). There, I add my package name and it generates a signature hash and a URL of the format msauth://<package-name>/<encoded signature hash>.

My code looks somewhat like this:

        var client = new MobileServiceClient("https://login.microsoftonline.com/<tenant ID>");
    var redirect_val_1 = "<package name>://easyauth.callback";
        var redirect_val_2 = "msauth://<my package name>/<the encoded signature hash>";
    client.login(AuthenticationProvider.Google, redirect_val_1)
    .then((user) => {
            console.log(`Logged In! UserID: ${user.userId}`);
            user.getProviderCredentials().then((result) => {
                console.log(`Surname: ${result.surname}`);
                console.log(`Given Name: ${result.givenName}`);
                console.log(`Name: ${result.name}`);
            });
        }, (e) => {
            console.log("Error Logging in!", e);
        });

I have tried this with both formats of the redirect URLs, as implied above (with the msauth and the easyauth options) and both cause the same error.

I have tried the proplugins version of this plugin, too, and that gives me a whole different error (Error Logging in! Error: java.lang.ClassCastException: com.tns.NativeScriptApplication cannot be cast to android.app.Activity). I don't know where to report that error and look for help.

I am using Nativescript 7.2.1, tns-android 6.5.3.

What am I doing wrong?

PeterStaev commented 3 years ago

@nmandyam , you should be using the ProPlugins version for sure. You can log issues in the ProPlugins git for the plugin: https://git.proplugins.org/Tangra/nativescript-azure-mobile-apps/-/issues the login is the same as the one you use to access the ProPlugins NPM.

I've just pushed version 4.0.1 that should resolve that class cast exception you were getting. Please try it and let me know.