We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

xtremebytes's avatar
xtremebytes
Explorer | Level 3
8 years ago
Solved

Dropbox invalid redirect_uri, must be an absolute uri

My app (Xamarin Forms) used to work with the Dropbox API authorisation but now it is showing me an error "invalid redirect_uri, must be an absolute uri". This started happening, probably after I upgraded the Visual Studio/Xamarin nuget package for Dropbox.Api to 4.8.0 from 4.7.0. Absolutely, nothing else in the code for Dropbox authorisation was changed.

 

Yet, the non-local URLs I have for OAuth2 redirection on my app begin with "https://". What could have gone wrong?

8 Replies

  • xtremebytes's avatar
    xtremebytes
    Explorer | Level 3
    8 years ago

    Digging in a bit deeper and looking at this code fragment:

     

     

    this._oauth2State = Guid.NewGuid ().ToString ("N");
    				var authorizeUri = DropboxOAuth2Helper.GetAuthorizeUri (OAuthResponseType.Token, DropboxAppKey, RedirectUri, this._oauth2State, false, false, null, true); //force re-authenticate
    				var webView = new WebView { Source = new UrlWebViewSource { Url = authorizeUri.AbsoluteUri } };
    				webView.Navigating += async (sender, e) => {
    					if (!e.Url.StartsWith (RedirectUri, StringComparison.OrdinalIgnoreCase)) {
    						// we need to ignore all navigation that isn't to the redirect uri.
    						return;
    					

    the e.Url used to match the RedirectUri, and now it doesn't. Instead, the e.Url now contains the RedirectUri as a query string parameter as follows:

     

    https://www.dropbox.com/oauth2/authorize?response_type=token&client_id=<hidden>&redirect_uri=<encoded_redirect_uri>&state=7396a67d6c604d45899fd5c588877d1f&force_reauthentication=true

     

    Is there something more that I am missing?

     

  • xtremebytes's avatar
    xtremebytes
    Explorer | Level 3
    8 years ago

    Seems like there were some issues with the new Xamarin Forms upgrade, .net and PCL stuff, so I rolled back all packages upgrades including Dropbox and now things are working.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    8 years ago
    Thanks for the post. I'm glad to hear you were able to get this working again.

    I'm not sure I follow this totally though, so just to be clear, are you saying there is a bug in the official Dropbox .NET SDK v4.8.0, or does the bug only appear to be in the "Xamarin Forms upgrade, .net and PCL stuff" ?
  • xtremebytes's avatar
    xtremebytes
    Explorer | Level 3
    8 years ago
    Thanks, Greg-DB It is difficult to blame the Dropbox .NET SDK v4.8.0. I need to upgrade the Dropbox SDK only and see if the problem persists. I will update this thread accordingly. Unfortunately, this may take a while before I get the time to do this.
  • Otti's avatar
    Otti
    New member | Level 2
    8 years ago

    @xtremebytes I ran into the exact same issue.

     

    My investigations:

    Just downgrading to Xamarin.Forms 2.5.1 resolved the issue for me. I kept the newer version of the dropbox sdk and the .NET standard stuff. The issue only exists on iOS, Android and UWP still work fine without downgrading.

     

    So it seems the problem occured in the Xamarin.Forms iOS stack while switching from Forms 2.5.1 to 3.0 or 3.1-Pre1.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,036 PostsLatest Activity: 54 minutes ago
412 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!