cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Update: Find information on Dropbox support during COVID-19 here
Close
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Dropbox invalid redirect_uri, must be an absolute uri

Explorer | Level 3

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?

1 Accepted Solution

Accepted Solutions
Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

New member | Level 2
New member | Level 2

@xtremebytes

This is the Xamarin Issue which causes the problem. Apparently work in progress:

[iOS] WebView.Source URL's are HTML encoded

 

Hope that helps.

 

View solution in original post

8 Replies 8
Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

Explorer | Level 3

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=<encode...

 

Is there something more that I am missing?

 

Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

Explorer | Level 3

Another note: the code is based on https://gist.github.com/tomcrusader/b0856a383bcdcf905c7a774c8c1b0879 -- and it used to work fine.

Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

Explorer | Level 3

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.

Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

Dropboxer
Dropboxer
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" ?
Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

Explorer | Level 3
Thanks, @Greg K. 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.
Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

New member | Level 2
New member | Level 2

@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.

Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

New member | Level 2
New member | Level 2

@xtremebytes

This is the Xamarin Issue which causes the problem. Apparently work in progress:

[iOS] WebView.Source URL's are HTML encoded

 

Hope that helps.

 

View solution in original post

Highlighted

Re: Dropbox invalid redirect_uri, must be an absolute uri

Explorer | Level 3

@Otti Thanks a lot for confirming this.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?