UWP - Microsoft.OneDrive.Sdk - fail to login with correct credentials

Viewed 94

We are using the OneDrive SDK inside our UWP application.

To login the user, we use the following code:

        OnlineIdAuthenticationProvider msaAuthenticationProvider = new OnlineIdAuthenticationProvider(
            new[] { "onedrive.readwrite" });
        try
        {
            await msaAuthenticationProvider.AuthenticateUserAsync();
            m_oneDriveClient = new OneDriveClient("https://api.onedrive.com/v1.0", msaAuthenticationProvider);
        }
        catch (Exception e)
        {
            s_log.ErrorFormat("OneDrive authentication failed: {0}", e.Message);
        }

In most of the cases, the login is successful.

Apparently, in cases when the user is an Administrator under a specific company domain, this method doesn't work and we are facing the following exception:

Exception of type 'Microsoft.Graph.ServiceException' was thrown

Obviously the credentials used by the user are correct and verified.

The credentials relate to a private account, which is NOT the one used to login into the Windows machine, BUT still is a recognized Microsoft account used e.g. to link OneDrive to the vary same machine (in fact, the user is able to see her files under Windows File Explorer / OneDrive!).

So I have the following questions:

  1. why only for specific users a login popup appears, while for others (e.g. private accounts) the login is automatic.
  2. how can we force the SDK to display the login popup.
  3. why there is an exception (and related authentication failure) for such credentials configuration.

Thank you!

0 Answers
Related