1

我想打开网络让用户允许我的应用访问他们的文件。代码在这里:

    config = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox) as DropBoxConfiguration;
    requestToken = DropBoxStorageProviderTools.GetDropBoxRequestToken(config, "XXXXXXXX", "YYYYYYYYY");
    AuthorizationUrl = DropBoxStorageProviderTools.GetDropBoxAuthorizationUrl(config, requestToken);

    Uri requestUri = new Uri(AuthorizationUrl);
    Debug.WriteLine("Done requestUri");

    Uri callbackUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
    Debug.WriteLine("Done callbackUri");

    WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, requestUri, callbackUri);
    if (result.ResponseStatus == WebAuthenticationStatus.Success)
    {
         ICloudStorageAccessToken accessToken = DropBoxStorageProviderTools.ExchangeDropBoxRequestTokenIntoAccessToken(config, "7nu03leznnz6x74", "ex3gge8av7kp9lq", requestToken);
    }

在构造函数()之前声明这些实例:

    static DropBoxRequestToken requestToken;
    static DropBoxConfiguration config;
    String AuthorizationUrl;

当我运行它时,我遇到了异常A first chance exception of type 'System.UriFormatException' occurred in System.ni.dllUri callbackUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();

如果我更改Uri callbackUri为类似的字符串 Uri callbackUri = new Uri("https://google.com");

它工作得很好,Debug.WriteLine("Done callbackUri");但发生了新的异常:

An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary在行中:

WebAuthenticationResult result = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, requestUri, callbackUri);

那么我做错了什么?我只想在打开网络授权后对应用程序进行回调调用。

谢谢你。

4

0 回答 0