Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TWebBrowser title cut off


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Sep 12, 2017 7:06 AM Last Post By: Jeff McKay
Jeff McKay

Posts: 4
Registered: 2/27/14
TWebBrowser title cut off  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 7, 2017 9:53 PM
I've got a C++ Builder 2009 application, where a form has a TWebBrowser component. I am using it with an OAuth2 application - that is, I give the user a certain URL, he logs on, then the web site does a redirect to a URL that I specify. That URL contains an authorization code. The way I retrieve the data is by using the OnTitleChange event. This passes in a WideString variable which contains the data. My problem is that this variable seems to be getting cut off at 259 bytes. Is that really a limitation, or could I be doing something wrong? Is there a better way that I should be doing this so my data does not get cut off?
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: TWebBrowser title cut off  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 8, 2017 1:36 PM   in response to: Jeff McKay in response to: Jeff McKay
Jeff McKay wrote:

The way I retrieve the data is by using the OnTitleChange event.

Why that event? Why not the OnDocumentComplete event instead?

This passes in a WideString variable which contains the data. My
problem is that this variable seems to be getting cut off at 259
bytes. Is that really a limitation, or could I be doing something
wrong?

Is there a better way that I should be doing this so my data
does not get cut off?

Why are you getting the data from the window title in the first place?
OAuth is not designed to be used that way. Any document content,
including its title, is just for human readability, not application
consumption. Any data that is relevant to the application, like
authorization codes and such, should be getting sent back to your app
as part of the HTTP redirect. The only thing the web browse should be
used for is prompting the user for credentials to their OAuth provider.
The rest of the OAuth handshake happens outside of the web browser
completely.

--
Remy Lebeau (TeamB)
Jeff McKay

Posts: 4
Registered: 2/27/14
Re: TWebBrowser title cut off  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 10, 2017 1:35 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Well I'll admit that I don't quite know what I'm doing, but I have used this technique successfully with Google OAuth. However Google does not return such a long string, so it is not getting cut off. I am not writing a web application, but a local, Windows application. I start up a TWebBrowser so that the user can enter his authentication. In the case of Microsoft, the redirect URL is https://login.microsoftonline.com/common/oauth2/nativeclient. I of course do not have the ability to put code on microsoftonline.com, but I want to intercept TWebBrowser sending Microsoft's redirect, and pick up the auth code that it generates. In fact OnTitleChange gets this, but not the entire thing. I briefly did try OnDocumentComplete, but it did not seem to get called during this exchange. I'll try to experiment further, but if you have any insight on why that didn't work, or other options to do what I want, I would appreciate it.

Remy Lebeau (TeamB) wrote:
Jeff McKay wrote:

The way I retrieve the data is by using the OnTitleChange event.

Why that event? Why not the OnDocumentComplete event instead?

This passes in a WideString variable which contains the data. My
problem is that this variable seems to be getting cut off at 259
bytes. Is that really a limitation, or could I be doing something
wrong?

Is there a better way that I should be doing this so my data
does not get cut off?

Why are you getting the data from the window title in the first place?
OAuth is not designed to be used that way. Any document content,
including its title, is just for human readability, not application
consumption. Any data that is relevant to the application, like
authorization codes and such, should be getting sent back to your app
as part of the HTTP redirect. The only thing the web browse should be
used for is prompting the user for credentials to their OAuth provider.
The rest of the OAuth handshake happens outside of the web browser
completely.

--
Remy Lebeau (TeamB)
Jeff McKay

Posts: 4
Registered: 2/27/14
Re: TWebBrowser title cut off  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 7:06 AM   in response to: Jeff McKay in response to: Jeff McKay
Disregard this last question - I got OnDocumentComplete to work - just a stupid mistake on my part.

Jeff McKay wrote:
Well I'll admit that I don't quite know what I'm doing, but I have used this technique successfully with Google OAuth. However Google does not return such a long string, so it is not getting cut off. I am not writing a web application, but a local, Windows application. I start up a TWebBrowser so that the user can enter his authentication. In the case of Microsoft, the redirect URL is https://login.microsoftonline.com/common/oauth2/nativeclient. I of course do not have the ability to put code on microsoftonline.com, but I want to intercept TWebBrowser sending Microsoft's redirect, and pick up the auth code that it generates. In fact OnTitleChange gets this, but not the entire thing. I briefly did try OnDocumentComplete, but it did not seem to get called during this exchange. I'll try to experiment further, but if you have any insight on why that didn't work, or other options to do what I want, I would appreciate it.

Remy Lebeau (TeamB) wrote:
Jeff McKay wrote:

The way I retrieve the data is by using the OnTitleChange event.

Why that event? Why not the OnDocumentComplete event instead?

This passes in a WideString variable which contains the data. My
problem is that this variable seems to be getting cut off at 259
bytes. Is that really a limitation, or could I be doing something
wrong?

Is there a better way that I should be doing this so my data
does not get cut off?

Why are you getting the data from the window title in the first place?
OAuth is not designed to be used that way. Any document content,
including its title, is just for human readability, not application
consumption. Any data that is relevant to the application, like
authorization codes and such, should be getting sent back to your app
as part of the HTTP redirect. The only thing the web browse should be
used for is prompting the user for credentials to their OAuth provider.
The rest of the OAuth handshake happens outside of the web browser
completely.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02