We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

olavolsf's avatar
olavolsf
Explorer | Level 3
3 years ago

Re: Dot Net SDK provided by Dropbox is not updated with TLS 1.2

Hi, 

I am trying to take the  dropbox V2 code here (the official Dropbox API v2 .NET SDK) to work in a website. I was able to make it work locally (localhost), with small changes. However, when uploaded the website to production server, it seems to me that http://127.0.0.1:52475/ does not work anymore. The git-hub code already mentions that ( "This loopback host is for demo purpose. If this port is not available on your machine you need to update this URL with an unused port.") The example of a blogDemo does that, I supose, but it is written in MVC (seemingly) and I use webforms. My question is: how can I change this address (http://127.0.0.1:52475/) to make the code run on a website (other changes are already done)? Is there any webform example?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    The "http://127.0.0.1:52475/" address is the address of the local server that the OauthBasic and OAuthPKCE examples use to locally receive the redirect during the OAuth app authorization flow. Those are console apps designed to be run locally to show how to process the OAuth flow, and are not meant to be deployed as web apps.

     

    If/when you're writing your own app (or if you're substantially modifying those example apps to deploy them as web apps), and you deploy an app on the internet, you'd need to set your web app's actual address where it can receive the redirect back during the authorization flow.

     

    You can find all of the examples for the .NET SDK here. For instance, here's an example of an MVC web app as you mentioned, and here's the line where it programmatically uses its hostname to build its redirect URI. Dropbox doesn't offer an example written for ASP.NET Web Forms in particular.

    • olavolsf's avatar
      olavolsf
      Explorer | Level 3

      Thank you, Greg, for your answer.

       

      I am doing that (using the Uri builder etc). Since I am still trying to make it work locally (but without the http://127.0.0.1:52475/ port), I am using the uri given to me by the builder, which is: https://localhost:44380/. I have this address authorized in the dropbox app (with the 'authorize' part too). The redirecting file is in the main directory (https://localhost:44380/MyLookBackPage.html), but this doesn't matter at this point for the following reason: The program is  passing the var authorizeUri =DropboxOAuth2Helper.GetAuthorizeUri(...) comand, receiving the authorizeUri bellow:

       

      authorizeUri = https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=mykeyommited_here&redirect_uri=https://localhost:44380/authorize&state=2fa0e30ca34d4387bfefaa5bc288a6b9&token_access_type=offline&scope=account_info.read account_info.write files.metadata.read files.metadata.write files.content.read files.content.write

       

      However, when I call the httplistener (https://localhost:44380/) add prefixes (none), getting https://localhost:44380/, and call for the listener start, the program gets out of the function giving the result uid=null. 

       

      Note that when I use the http://127.0.0.1:52475/ port, nothing such happens. After the authorization step I get the authorizeUri:

      authorizeUri = https://www.dropbox.com/oauth2/authorize?response_type=code&client_id=mykeyommited_here&redirect_uri=http://127.0.0.1:52475/authorize&state=45673cb4324441e0921db1d93802bf32&token_access_type=offline&scope=account_info.read account_info.write files.metadata.read files.metadata.write files.content.read files.content.write

       

      which is obviously the same as before, buth with the redirect_uri given by http://127.0.0.1:52475/authorize. The httplistener then uses this uri (instead of the http://localhost:44380/ of the previous test) everything is ok and the System.Diagonstics.Process is called, presenting the authorization page and the Oauth flow proceeds normally, issuing a valid uid (and I can download the file from dropbox to my machine). 

       

      From this test, it seems to me that it is the use of http://localhost:44380/, which is the Uri I get from example you cited and which I was previously using. The listener is getting this address and issuing an error (looks like).

       

      Sorry for the extent of the message, but I think it would be usefull to give you a detailed account of the situation. Can you help me?

       

      Best regards.

       

      • olavolsf's avatar
        olavolsf
        Explorer | Level 3

        Well. I've got the problem. One cannot create a listener for a already running process. In the console application it is ok, because the process is not openned yet. Ok. I will give a try in other changes to make a webform oauth2 application regardin dropbox.

         

        Best regards.