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: 

DropboxOAuth2Helper GetAuthorizeUri removing port from redirecturl?

DropboxOAuth2Helper GetAuthorizeUri removing port from redirecturl?

fmmmf
Explorer | Level 3
Go to solution

When using the DropboxOAuth2Helper.GetAuthorizeUri - we pass in the following params:

 

var response  = DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Code, ClientId, redirectUrl, state);

 

Where the redirectUrl is a link similar to the following:

 

 

https://my-site.domain.com:443/rest-of/the/url/auth-complete

 

However the response that comes from it doesn't include the '443' and that seems to be causing issues when trying to authenticate.

Ie. response is as follows (example):

 

https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=y7c53f1wctrfmw8&redirect_uri=https:%2F%2Fmy-site.domain.com%2Frest-of%2Fthe%2Furl%2Fauth-complete&state=MxuufKLcqtGRLQLDNgaYnsvowunHhvfnpoKZKEIvamanPmwvIMTMoqhDBpjH
WBsddOiTEeDvfoEPgfEzolugXskJnzcOpQyoMtmRkkhqbCqmsaIizwQpBzvSeEsJbjMPXfZapCnvUIKfgToizDMnbxRPhzPXnYpUUOjFYhphBDHduROpUusecDHIRJSnYipvtrlQITt

 

Does anyone know what could be causing this? Is this an inherent part of how this function should work?

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

The Dropbox .NET SDK builds a Uri from the redirectUri string you provide, using the Uri Constructor. The Uri Class canonicalizes URIs, including:

 

"Removes default and empty port numbers."

 

The "443" port is default for SSL/TLS, so it's implied by "https://" and shouldn't be necessary.

 

Can you elaborate on the issues you're running in to with it omitted though?

View solution in original post

5 Replies 5

Greg-DB
Dropbox Staff
Go to solution

The Dropbox .NET SDK builds a Uri from the redirectUri string you provide, using the Uri Constructor. The Uri Class canonicalizes URIs, including:

 

"Removes default and empty port numbers."

 

The "443" port is default for SSL/TLS, so it's implied by "https://" and shouldn't be necessary.

 

Can you elaborate on the issues you're running in to with it omitted though?

fmmmf
Explorer | Level 3
Go to solution

Hi Greg, thanks for the reply!

 

Since the GetAuthorizeUri method seemed to be removing the 443 it was a mismatch between the redirect url sent in there and the one we were sending into the ProcessCodeFlowAsync method - although to us, the url we were sending into both of them was the same. Once we also removed the 443 from the PCFA method, we were able to authenticate with dropbox.

 

The removal of the default port was not inherently obvious in these docs when we went looking for what was happening: https://dropbox.github.io/dropbox-sdk-dotnet/html/M_Dropbox_Api_DropboxOAuth2Helper_GetAuthorizeUri....

fmmmf
Explorer | Level 3
Go to solution
I should specify that the error we were getting was:
An unhandled exception has occurred: invalid_grant (1fff7674)
Dropbox.Api.OAuth2Exception: invalid_grant

Greg-DB
Dropbox Staff
Go to solution
I see, thanks for the information. In that case, you should register the redirect URI without the port. I'll ask the team to clarify this in the documentation.

fmmmf
Explorer | Level 3
Go to solution
Yes we have, thank you!
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    fmmmf Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?