Xamarin.forms 我将引发invalidRequest异常:';Microsoft.Graph.ServiceException';在mscorlib.ni.dll中

Xamarin.forms 我将引发invalidRequest异常:';Microsoft.Graph.ServiceException';在mscorlib.ni.dll中,xamarin.forms,uwp,microsoft-graph-api,onedrive,Xamarin.forms,Uwp,Microsoft Graph Api,Onedrive,我正在将Onedrive SDK与我的Xamarin应用程序的UWP部分集成。按下下载按钮后,我会看到Onedrive登录页面,但它会在这一行中抛出上述错误: try { var appFolder = await OneDriveClient.Drive.Special.AppRoot.Request().GetAsync(); Debug.WriteLine(appFolder.Name); } catch (ServiceE

我正在将Onedrive SDK与我的Xamarin应用程序的UWP部分集成。按下下载按钮后,我会看到Onedrive登录页面,但它会在这一行中抛出上述错误:

     try
    {
        var appFolder = await OneDriveClient.Drive.Special.AppRoot.Request().GetAsync();
        Debug.WriteLine(appFolder.Name);
    }
    catch (ServiceException e  )
    {
        Debug.WriteLine(e.Message +"    " +  e.Error.Code);

    }
以下是完整的相关代码:

     public async Task Download(string filename)
{
    //AccountSelectionLoaded();
    await InitializeClient();
    try
    {
        var appFolder = await OneDriveClient.Drive.Special.AppRoot.Request().GetAsync();
        Debug.WriteLine(appFolder.Name);
    }
    catch (ServiceException e  )
    {
        Debug.WriteLine(e.Message +"    " +  e.Error.Code);

    }

    var file = await OneDriveClient.Drive.Special.AppRoot.Children[filename].Content.Request().GetAsync();

    //var fileStream = await fileBuilder.Content.Request().GetAsync();

    IStorageFile appFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("test.db3",
                        CreationCollisionOption.OpenIfExists);
    byte[] fileBytes;
   using (DataReader reader = new DataReader(file.AsInputStream()))
        {
            fileBytes = new byte[file.Length];
            await reader.LoadAsync((uint)file.Length);
            reader.ReadBytes(fileBytes);
        }
   Debug.WriteLine(fileBytes.Length);
    Debug.WriteLine("Writing");
    await FileIO.WriteBytesAsync(appFile, fileBytes);
    Debug.WriteLine("End of writing");       
}

private async Task InitializeClient()
{
    if (OneDriveClient == null)
    {
        Task authTask;
        var msaAuthProvider = new MsaAuthenticationProvider(oneDriveConsumerClientId,oneDriveConsumerReturnUrl,scopes);
        await msaAuthProvider.AuthenticateUserAsync();
        OneDriveClient = new OneDriveClient(oneDriveConsumerBaseUrl, msaAuthProvider);

        AuthenticationProvider = msaAuthProvider;


    }
}

感谢您报告此问题。事实上,我们可以在UWP应用程序中使用OneDrive.NET SDK看到相关问题

我将通过内部途径报告这一问题

作为解决方法,请参阅此博客:

Laurent Bugnon描述了在UWP应用程序中启用OneDrive功能的详细步骤(以及一个示例)

private IOneDriveClient _client;
public MainPage()
{
  InitializeComponent();
  AuthenticateButton.Click += async (s, e) =>
  {
    var scopes = new[]
    {
      "onedrive.readwrite",
      "onedrive.appfolder",
      "wl.signin"
    };
    _client = OneDriveClientExtensions.GetClientUsingOnlineIdAuthenticator(
      _scopes);
    var session = await client.AuthenticateAsync();
    Debug.WriteLine($"Token: {session.AccessToken}");
  };
}

当时,该项目正在使用目前仍在运行的

我正在处理此问题有任何更新吗?你查过我的答案了吗?