HTMLViewer View URL Question

Hello,

I am working with the Dropbox API and I am noticing that I am not seeing the redirect URL in the DocumentComplete nor the CancelLoad events until and only after I force a reload using javascript.

Does this sound right meaning why do I have to force a reload to see the proper Redirect URL?

Any advice would be appreciated.
Thanks

Which part of the DropBox API specifically? They do some fancy things with redirects and status codes when you view a shared link/file.

The authorize url.

  https://www.dropbox.com/1/oauth2/authorize?client_id=<client ID>&response_type=token&redirect_uri=<redirect>

I see the proper token/bearer/uid BUT only after I manually refresh the HTMLViewer Control via javascript.

So not even to a file, hmmm
What are you getting back for a HTTP Status? Poking at the HTML Viewer docs (as if I haven’t been neck deep in them for the last two weeks) there’s no way to access the headers, perhaps something is coming in via DocumentProgressChanged? Or maybe even Error o.O

I’m not even looking at the Dropbox API right now, so take all my suggestions as if they were total guesses…

Also, isn’t the dropbox auth supposed to open in a web browser? I can’t recall from the last time I needed to auth something, but I thought that’s how it worked.

[quote=162362:@Tim Parnell]So not even to a file, hmmm
What are you getting back for a HTTP Status? Poking at the HTML Viewer docs (as if I haven’t been neck deep in them for the last two weeks) there’s no way to access the headers, perhaps something is coming in via DocumentProgressChanged? Or maybe even Error o.O

I’m not even looking at the Dropbox API right now, so take all my suggestions as if they were total guesses…

Also, isn’t the dropbox auth supposed to open in a web browser? I can’t recall from the last time I needed to auth something, but I thought that’s how it worked.[/quote]

Ill check the error event as that didn’t yield me anything last night, but I will double check. HTMLViewer is enough of a browser to pass the interaction as it is working well, minus the need for the reload for my to catch the Token/Bearer/UID. Once I get this I use the api.dropbox.com to interface via HTTPSecureSocket to finish the oAuth2.0 process.

Thanks for the ideas Tim!

No dice on the DocumentProgressChanged event. It shows the same URL that I loaded w/ the viewer. The same as the DocumentComplete, until I reload it then I get the redirected URL which contains what I need. I can make a work around, but I figured I’d as to see how to address this cleanly first.

I am calling my original URL with:

 HTMLViewer1.LoadURL( "https://www.dropbox.com/1/oauth2/authorize?client_id=<client ID>&response_type=token&redirect_uri=<redirect>")


Thanks!

This issue appears to be a Xojo HTMLViewer issue. I can attach a sample project if Greg or Norman could lend a hand to confirm for me please? I’d be happy to open a feedback case but I don’t want to waste anyone’s time if there is still something to do. Thanks again!

Any thoughts on this? This issue belongs to the open source Dropbox API SDK I am finishing for Xojo.

Thanks!

Ok I have changed the title of this question. I really only need to understand how I can obtain the URL that is present within HTMLViewer. I am messing with javascript but I am not having luck yet.

Any advice is much appreciated.
Thanks
Mike

No matter what the HTMLViewer using R2.1 under Mac always returns the Original URL when I need the redirected URL. You simply right click on HTMLViewer and reload. It THEN shows the correct Redirected URL.

Any thoughts?
Thanks

What code do you have in CancelLoad? That’s usually where I see the problem in these cases.

Nothing in CancelLoad.

This is in DocumentComplete (I have it available to run through each document complete hit for testing).

  // PARSE ACCESS CODE INFO FROM REDIRECT URL
  ParseCode(URL)
  Try
    ChartOpenCircle1.Visible = False
    ChartOpenCircle1.Enabled = False
  Catch
  End Try
  // PARSE CODE
  Dim Parse_AccessCode_RegEx as RegEx
  Dim Parse_AccessCode_RegExMatch as RegExMatch
  Dim Parse_AccessCode_HitText as String
  Parse_AccessCode_RegEx = New RegEx
  Parse_AccessCode_RegEx.Options.CaseSensitive = False
  Parse_AccessCode_RegEx.Options.Greedy = True
  Parse_AccessCode_RegEx.Options.StringBeginIsLineBegin = True
  Parse_AccessCode_RegEx.Options.StringEndIsLineEnd = True
  Parse_AccessCode_RegEx.Options.MatchEmpty = True
  Parse_AccessCode_RegEx.Options.TreatTargetAsOneLine = False
  Parse_AccessCode_RegEx.SearchPattern = "(?<=\\?code=).+"
  
  Parse_AccessCode_RegExMatch = Parse_AccessCode_RegEx.Search(PageContent)
  if Parse_AccessCode_RegExMatch <> nil then
    Parse_AccessCode_HitText = Trim(Parse_AccessCode_RegExMatch.SubExpressionString(0))
    Common_Module.DropboxOAUTHSocket.Dropbox_Access_Code = Parse_AccessCode_HitText
  end if
  

Right now I have a work around in place ;(

I catch the “redirected site’s title” and force a reload of the page to get the proper Redirected URL in the DocumentComplete event.

TitleChanged Event
  if newTitle = "Google" AND siteCounter = 0 Then
    HTMLViewer1.ExecuteJavaScript("location.reload();")
    siteCounter = siteCounter + 1
  end if

What code are you using to get the redirected URL address?

TitleChanged Event
if newTitle = “Google” AND siteCounter = 0 Then
HTMLViewer1.ExecuteJavaScript(“location.reload();”)
siteCounter = siteCounter + 1
end if

This is the code that forces the reload after I land on the Redirected URI. Only after this reload is when the DocumentCompleted event fires with the correct Redirected URL ie. with my access token. :slight_smile:

I filed a detailed feedback case with an attached sample project for this HTMLViewer issue.

<https://xojo.com/issue/37923>

Thanks!

[quote=162834:@Mike Cotrone]TitleChanged Event
if newTitle = “Google” AND siteCounter = 0 Then
HTMLViewer1.ExecuteJavaScript(“location.reload();”)
siteCounter = siteCounter + 1
end if

This is the code that forces the reload after I land on the Redirected URI. Only after this reload is when the DocumentCompleted event fires with the correct Redirected URL ie. with my access token. :)[/quote]
Jepp - theses lines do the magic. And solve one of my major problems. THANK YOU!