OneDriveService尝试登录NullReferenceException

人气:959 发布:2022-09-22 标签: wpdevelop

问题描述

我编写的UWP项目包含允许用户上传谷歌驱动器中的文件。我正在使用Microsoft.Toolkit.Services.OneDrive.OneDriveService连接到一个驱动器。

I write UWP project that contains allowing user to upload files in google drive. I'm using Microsoft.Toolkit.Services.OneDrive.OneDriveService for connection to one drive.

var scopes = new string[] {"files.read" };
OneDriveService.Instance.Initialize("my app code", scopes, null, null);
if(await OneDriveService.Instance.LoginAsync()) //here!
Frame.Navigate(typeof(OneDrivePage));

我是已经输入的登录名和密码,但在此之后抛出了NullReferenceException(对象引用没有设置为对象的实例)。

I'd enetered login and password, but after this NullReferenceException (Object reference not set to an instance of an object) thrown.

我不知道什么可以是原因。我已经用Google搜索了,但仍然不明白。

I have no idea what can be a reason. I've googled about it, but still dont understand.

这是堆栈跟踪:

在Microsoft.Identity.Client.TokenCache.SaveAccessAndRefreshToken(AuthenticationRequestParameters requestParams,TokenResponse response) 在Microsoft.Identity.Client.Internal.Requests.RequestBase.SaveTokenResponseToCache() 在Microsoft.Identity.Client.Internal.Requests.RequestBase.PostTokenRequest() 在Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync() 在Microsoft.Identity.Client.PublicClientApplication.AcquireTokenForLoginHintCommonAsync(授权机构,IEnumerable`1范围,IEnumerable`1 extraScopesToConsent,String loginHint,UIBehavior行为,字符串extraQueryParameters,UIParent parent,ApiIds apiId) at Microsoft.Identity.Client.PublicClientApplication.AcquireTokenAsync(IEnumerable`1 scopes,String loginHint,UIParent parent) 在Microsoft.Toolkit.Services.MicrosoftGraph.MicrosoftGraphAuthenticationHelper.GetUserTokenV2Async(String appClientId,UIParent uiParent,String redirectUri,String loginHint) 在Microsoft.Toolkit.Services.MicrosoftGraph.MicrosoftGraphAuthenticationHelper.GetUserTokenV2Async(String appClientId,String loginHint) 在Microsoft.Toolkit.Services.MicrosoftGraph.MicrosoftGraphService.LoginAsync(String loginHint) 在Microsoft.Toolkit.Services.OneDrive.OneDriveService.LoginAsync() 在MediaImporter.Views.RootPage.ImportOneDrive_Click(对象发件人,RoutedEventArgs e)

at Microsoft.Identity.Client.TokenCache.SaveAccessAndRefreshToken(AuthenticationRequestParameters requestParams, TokenResponse response) at Microsoft.Identity.Client.Internal.Requests.RequestBase.SaveTokenResponseToCache() at Microsoft.Identity.Client.Internal.Requests.RequestBase.PostTokenRequest() at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync() at Microsoft.Identity.Client.PublicClientApplication.AcquireTokenForLoginHintCommonAsync(Authority authority, IEnumerable`1 scopes, IEnumerable`1 extraScopesToConsent, String loginHint, UIBehavior behavior, String extraQueryParameters, UIParent parent, ApiIds apiId) at Microsoft.Identity.Client.PublicClientApplication.AcquireTokenAsync(IEnumerable`1 scopes, String loginHint, UIParent parent) at Microsoft.Toolkit.Services.MicrosoftGraph.MicrosoftGraphAuthenticationHelper.GetUserTokenV2Async(String appClientId, UIParent uiParent, String redirectUri, String loginHint) at Microsoft.Toolkit.Services.MicrosoftGraph.MicrosoftGraphAuthenticationHelper.GetUserTokenV2Async(String appClientId, String loginHint) at Microsoft.Toolkit.Services.MicrosoftGraph.MicrosoftGraphService.LoginAsync(String loginHint) at Microsoft.Toolkit.Services.OneDrive.OneDriveService.LoginAsync() at MediaImporter.Views.RootPage.ImportOneDrive_Click(Object sender, RoutedEventArgs e)

推荐答案

由于问题与OneDrive有关,您可能需要在Stack Overflow中使用标记"OneDrive"来询问此问题。 OneDrive团队是 回答 OneDrive开发问题在Stack Overflow上。

Since the problem is more related to OneDrive, you might need to ask about this inStack Overflow withtag "OneDrive". TheOneDrive team isanswering OneDrive development questions on Stack Overflow.

祝你好运,

Roy

813