cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Dropbox invalid redirect_uri, must be an absolute uri

Dropbox invalid redirect_uri, must be an absolute uri

xtremebytes
Explorer | Level 3
Go to solution

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

Otti
New member | Level 2
Go to solution

@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

xtremebytes
Explorer | Level 3
Go to solution

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?

 

xtremebytes
Explorer | Level 3
Go to solution

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

xtremebytes
Explorer | Level 3
Go to solution

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
Dropbox Staff
Go to solution
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
Explorer | Level 3
Go to solution
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
New member | Level 2
Go to solution

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

Otti
New member | Level 2
Go to solution

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

 

xtremebytes
Explorer | Level 3
Go to solution

@Otti Thanks a lot for confirming this.

Need more support?