cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We want to make our Community work for you and we need your help. Take our short survey!
Close

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: 

Sign-in stuck on my laptop - works perfectly on PC

Highlighted

Sign-in stuck on my laptop - works perfectly on PC

Collaborator | Level 8

Have downloaded a bunch of code updates to my laptop,which is currently connected to the same router as my PC (so minimal difference in IP address) and when I try to signin my app to Dropbox it is just stuck there (as I write this it's been more than 15 minutes, on my 2nd try). I confirmed still works on PC - signed in, signed out, signed in again in under a minute, so no prob with user/password, nor the Dropbox server, and yet the laptop one is just hanging. Dropboxsignin.png

Is there something equivalent to "clear cookies" that I need to do, because I can't see anything to click on that would facilitate such a thing.
This is in C#/.NET. This is where I'm stuck...

void WebViewOnNavigating(object Sender,WebNavigatingEventArgs e)
{
DebugUtil.ConsoleWrite(debugOn,$"{nameof(WebViewOnNavigating)} has started");
if (!e.Url.StartsWith(RedirectUri,StringComparison.OrdinalIgnoreCase)) {
DebugUtil.ConsoleWrite(debugOn,"StringComparison failed");
return;
}
else {
DebugUtil.ConsoleWrite(debugOn,"StringComparison success");
};
DebugUtil.ConsoleWrite(debugOn,"about to start try statement");
try {
DebugUtil.ConsoleWrite(debugOn,"awaiting response");
OAuth2Response result=DropboxOAuth2Helper.ParseTokenFragment(new Uri(e.Url));
// etc.

The debug statements are indicating it's stuck at the "If (!e.Url....." statement. On PC it fails a couple of times and then succeeds. On laptop it fails a couple of times and nothing else happens. The redirecturi I'm using is https://localhost:52475/authorise. I tried http as well - both work on PC, both getting stuck on laptop. Do I maybe need to use a different port on the laptop? I'm not sure how to check that (I used that one to begin with as it was mentioned somewhere here as the one you guys use).

P.S. this is on Windows 10. I just thought to check the versions and my PC is on 1903 but my laptop is on 1909 (I don't know why my laptop is ahead of my PC) - is there maybe a signin issue from 1909? Oh, and also my PC is Pro but laptop is Home.

thanks,

  Donald.

 

8 Replies 8
Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Dropboxer
Dropboxer

Thanks for the report! Based on your code though, I see that you're running this in a web view, which is not officially supported, per the /oauth2/authorize documentation. (Web views are more prone to issues like this, and are being disallowed by other providers anyway, such as Google, who we support as an sign-in provider for Dropbox.)

That being the case, please switch to using the system browser for the app authorization flow and let me know if you're still seeing any issues there.

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Collaborator | Level 8

Hi Greg,

   Ok,  but that was how I was taught to do it and is the only way I know. Do you have some sample C#/.NET code for how to do it this other way? I don't see any in the link you gave me, nor any links within that.

 

thanks,

  Donald.

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Dropboxer
Dropboxer

Sure, there's more information and sample code in the documentation for DropboxOAuth2Helper in the .NET SDK

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Collaborator | Level 8

"HttpListener is created to listen to the RedirectUri which will later receive redirect callback from the server. Start() is called to launch a native browser and navigate user to the authorize URI".

Hmmm, I remember now trying to do this back in the beginning (because it was in your .NET code) and never succeeded in getting it working. Will have another look at it though. Thanks.

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Collaborator | Level 8

Hey Greg,

Ok, I've gone back and revisited the code I never got working, which was based on SimpleTest. Where I got stuck was stuff around index.html in HandleOAuth2Redirect. At the time you said it wasn't really necessary (just a page that is displayed to the user, which I don't need), and I think I have an idea now how to resolve that, however the way I did get it working in the end, following someone's blog, was using 

OAuth2Response result=DropboxOAuth2Helper.ParseTokenFragment(new Uri(e.Url));

in a webview, which is way simpler (much fewer lines of code) than the way it's done in SimpleTest (ParseTokenFragment does all the heavy lifting for you). Would I be able to use that with this different approach? i.e. once I get to http.Start(), what would the next few lines of code look like if I wanted to use ParseTokenFragment instead? (and if this is indeed possible, maybe update SimpleTest to reflect this simpler approach?)

thanks,

   Donald.

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Dropboxer
Dropboxer

Using a web view for the app authorization flow is not officially supported, so I can't recommend doing so.

In any case, if you call ParseTokenFragment and it returns successfully, the return value will be a OAuth2Response. You can get the access token from OAuth2Response.AccessToken.

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Collaborator | Level 8

"Using a web view for the app authorization flow is not officially supported, so I can't recommend doing so"

Ok, I understand that. I'm asking if you can use ParseTokenFragment with a native browser (as per your recommendation), and if so what would the code to do so look like?

Highlighted

Re: Sign-in stuck on my laptop - works perfectly on PC

Dropboxer
Dropboxer

Yes, you can certainly use ParseTokenFragment with the native system browser flow. That's shown in the example here: https://dropbox.github.io/dropbox-sdk-dotnet/html/T_Dropbox_Api_DropboxOAuth2Helper.htm

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?