Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Wed Oct 16, 2019 4:24 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: HTTP authentication problem
PostPosted: Fri Mar 18, 2011 10:13 am 
Offline

Joined: Tue Jun 16, 2009 3:23 am
Posts: 23
I'm relatively new to real studio and cannot seem to get http authentication to worky. The web site I'm trying to enter has a "basic" authentication method which simply asks for Username and Password. Screen scraping software has no problem getting thru, but I'm lost after trying several different ways, a couple I've found in this forum.

The way I favor most is simply setting of Name and Password when the AuthenticationRequired event fires eg:

Function AuthenticationRequired ( Realm as string, Headers as InternetHeaders, ByRef Name as String, ByRef Password as String ) as Boolean

Name = "abc"
Password = "xyz"
Return True

However, if I Return TRUE is doesn't continue/fire and locks up, but if Return FALSE it just fails.....

It may just be a lack of knowledge on wen pages and authentication... but I'm lost... can anyone help me ?

Martin


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTP authentication problem
PostPosted: Tue Mar 22, 2011 12:59 pm 
Offline

Joined: Thu Dec 16, 2010 1:22 pm
Posts: 188
I found this code in an old program I wrote awhile back after struggling with the same issue. It worked then...

I don't have a site to test it on currently, but the proper way to send authorization to a web site is
to concatenate the user name and the password separated by a colon, base64 encode the string, precede it with the word "Basic " and then set all that to the Authorization Header
http://en.wikipedia.org/wiki/Basic_acce ... entication
as below

dim authstring as string
authstring=encodeBase64(USER+":"+PASSWORD)
httpsocket1.setrequestHeader ("Authorization","Basic "+authstring)


I imagine the AuthorizationRequired event should work in a similar matter, and my guess would be you use it the same way you are trying, but again, I don't have a way of playing with it. Maybe base64 encode the user and password first?


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTP authentication problem
PostPosted: Wed Apr 13, 2011 2:25 pm 
Offline

Joined: Tue Jun 16, 2009 3:23 am
Posts: 23
Sorry for delay in responding. Thanks for this suggestion but it doesn't work for me. I made sure I was call the httpsocket async and did as you suggested. I also tried setting the Name and Password byref strings and returning True. None of these work and I still get a 401 error.
Any further suggested appreciated anyone...


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTP authentication problem
PostPosted: Wed Apr 13, 2011 4:50 pm 
Offline

Joined: Thu Dec 16, 2010 1:22 pm
Posts: 188
hmmm... is it the actual "HTTP Authentication Request" and not a login on a web page, right?
check out my recent post here (near the bottom) it involves downloading a pic from a URL, but it also required authentication first as well.
http://forums.realsoftware.com/viewtopic.php?f=10&t=38496&start=0
I did indeed confirm that setting the username and password in the AuthenticationRequired event and then returning True works.
It also worked with my old, round-a-bout, method of setting the HTTPRequestHeader with the encoded user/pass. So a "standard" web authorization should work either way.

You might fire-up wireshark and see what is going on behind the scenes with a manual browser login compared to your httpsocket trying to login.

Is it maybe cookie related?? I don't know if that could have anything to do with it.

If you want, I'll try working it out on your particular site (email me your details)... provided it isn't holding any government secrets! :)

I'm kinda curious myself why it's not working and maybe we can solve it for others that are in the same boat - I like a good challenge! :lol:


Top
 Profile  
Reply with quote  
 Post subject: Re: HTTP authentication problem
PostPosted: Sat May 14, 2011 12:05 am 
Offline

Joined: Tue Jun 16, 2009 3:23 am
Posts: 23
thank you all... You advice solved it ! :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group