在 上VS2019
,当将此OneDrive 示例与Microsoft 的 UWP 一起使用时,我收到以下错误。在线搜索会显示一些相关链接(例如this或this或this),但它们的上下文不同(因为它们使用 Web 应用程序或 Python 等):
AADSTS50011:请求中指定的回复 URL 与为应用程序配置的回复 URL 不匹配:'55dbdbc9-xxxxxxxxxxxxx-a24'
我已按照示例的说明注册和配置Redirect URI
我选择的应用程序Public client (mobile & desktop)
,并将其值设置为https://login.microsoftonline.com/common/oauth2/nativeclient
问题:我可能做错了什么,我们如何解决这个问题?
更新:
错误发生在FolderLoaded?.Invoke(this, EventArgs.Empty);
如下所示的方法行。OneDriveList.xaml.cs
这是示例中文件的第 180 行。这不是错误OperationCanceledException
,因为错误转到第二个 catch 语句。
private async Task LoadFolderAsync(string id = null)
{
// Cancel any previous operation
_cancellationTokenSource?.Cancel();
_cancellationTokenSource = new CancellationTokenSource();
// Check if session is set
if (AuthenticationService == null) throw new InvalidOperationException($"No {nameof(AuthenticationService)} has been specified");
// Keep a local copy of the token because the source can change while executing this function
var token = _cancellationTokenSource.Token;
// Add an option to the REST API in order to get thumbnails for each file
// https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_thumbnails
var options = new[]
{
new QueryOption("$expand", "thumbnails"),
};
// Create the graph request builder for the drive
IDriveRequestBuilder driveRequest = AuthenticationService.GraphClient.Me.Drive;
// If folder id is null, the request refers to the root folder
IDriveItemRequestBuilder driveItemsRequest;
if (id == null)
{
driveItemsRequest = driveRequest.Root;
}
else
{
driveItemsRequest = driveRequest.Items[id];
}
// Raise the loading event
FolderLoading?.Invoke(this, EventArgs.Empty);
try
{
try
{
// Make a API request loading 50 items per time
var page = await driveItemsRequest.Children.Request(options).Top(50).GetAsync(token);
token.ThrowIfCancellationRequested();
// Load each page
await LoadGridItemsAsync(page, token);
token.ThrowIfCancellationRequested();
}
finally
{
// Raise the loaded event
FolderLoaded?.Invoke(this, EventArgs.Empty);
}
}
catch (OperationCanceledException)
{ }
catch (Exception ex)
{
// Raise the error event
LoadingError?.Invoke(this, ex);
}
}