microsoftgraph / msgraph-sdk-android

Microsoft Graph SDK for Android! https://graph.microsoft.io
Other
51 stars 43 forks source link

Login Screen Hanges After pressing the Cancel button ! #48

Closed AnilSony closed 7 years ago

AnilSony commented 7 years ago

My name is Anil, My android app screen gets hangs after pressing the cancel button from the Login screen. I tested with different OS versions (KitKat, Lollipop & MarshMallow) it results the same. There is no way to escape from this screen, Device hardware button functionalities seems not working after this.Please Help.

sdk_loginscreen

kumaraish commented 7 years ago

I too am facing the same issue for long ..

AnilSony commented 7 years ago

It would be helpful for me, if you suggest any fixes for this issue at that time?

caitlinrussell commented 7 years ago

I'm not able to repro this. Could you show the code you are using to handle the authentication? You need to ensure that you handle this in the onError callback. It also would be helpful to know which version of the ADAL library you are using, as this might be an error in that package. The newest version of this library does not include a back button, so there is no opportunity for the user to cancel the login process.

AnilSony commented 7 years ago

Hi,

Dependencies compile('com.google.code.gson:gson:2.3.1') compile('com.microsoft.graph:msgraph-sdk-android:1.2.+') compile 'com.microsoft.graph:msa-auth-for-android-adapter:0.9.+'

Code

private MSAAuthAndroidAdapter mAuthAdapter; private final AtomicReference mGraphClient = new AtomicReference<>();

private void initOneDrive() { mAuthAdapter = new MSAAuthAndroidAdapter(mContext.getApplication()) { @Override public String getClientId() { return OneDriveConstants.APP_ID; }

        @Override
        public String[] getScopes() {
            return new String[]{
                    "https://graph.microsoft.com/Files.Read",
                    "https://graph.microsoft.com/User.Read"
            };
        }
    };

    // Create the service client from the configuration
    final com.microsoft.graph.core.IClientConfig config = com.microsoft.graph.core.DefaultClientConfig.createWithAuthenticationProvider(mAuthAdapter);

    mGraphClient.set(new GraphServiceClient.Builder()
            .fromConfig(config)
            .buildClient());

     requestloginScreen();
}

private void requestloginScreen() { try { // Popup the login screen from SDK. mAuthAdapter.login(mContext, new ICallback() { @Override public void success(final Void aVoid) { Log.d(TAG, "Success: " + aVoid); }

            @Override
            public void failure(com.microsoft.graph.core.ClientException e) {
                Log.d(TAG, "Exception: " + e.getMessage());
            }

        });
    }
    catch(Exception ex) {
        Log.d(TAG, "Exception: " + ex.getMessage());
    }
}
caitlinrussell commented 7 years ago

The library you're using for authentication is here: https://github.com/microsoftgraph/msgraph-sdk-android-msa-auth-for-android-adapter You are welcome to move that bug there, however, this is not a supported authentication library. The best route would be to switch to using ADAL if you are able to (if you are using this for school or work). The library is here. Otherwise, the AAD team is working on an MSA library for Android that should be available relatively soon if you are able to develop around this bug until that time.

caitlinrussell commented 7 years ago

My apologies; this has already been reported here: https://github.com/OfficeDev/msa-auth-for-android/issues/32. I would still recommend the above advice, as this issue has been open for some time.

AnilSony commented 7 years ago

It's ok. Thanks for your great help, hope MSA team will correct this issue.