1

I want to open the web to let user allow my app to access their files. The code is here:

    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);
    }

With these instances declared before the constructor():

    static DropBoxRequestToken requestToken;
    static DropBoxConfiguration config;
    String AuthorizationUrl;

When I run it, I have the exception A first chance exception of type 'System.UriFormatException' occurred in System.ni.dll at Uri callbackUri = WebAuthenticationBroker.GetCurrentApplicationCallbackUri(); line.

And if I change Uri callbackUri to a string like Uri callbackUri = new Uri("https://google.com");

it works just fine toDebug.WriteLine("Done callbackUri"); but new exception occurs:

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

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

So what did I do wrong? I just want to make the callback call to the app after opening web authorizing.

Thank you.

Tran Hoai Nam
  • 1,273
  • 2
  • 18
  • 35

0 Answers0