FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour basic access authentication
Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
basic access authentication
Posted: Tue Jul 28, 2020 10:56 PM
Dear community,

I am not familiar with basic access authentication.
Ist there a way to post an XML with basic access authentication?
I have tried this code, but I think it is just nonsense....
Code (fw): Select all Collapse
loHyperlink := CreateObject( 'Microsoft.XMLHTTP' )

cHttpSend := [{ "user": ]+hb_base64Encode(alltrim(cHotelCode)+":")+[, "password": ]+hb_base64Encode(alltrim( cMsgPassword ))+[}]

loHyperlink:Open( "POST" ,cUrl, .F. )
loHyperlink:SetRequestHeader( "Accept" , "application/json" )
loHyperlink:SetRequestHeader( "Content-Type" , "application/json" )

loHyperlink:SetRequestHeader( "Authorization" , cHttpSend )
loHyperlink:Send( cXML )


I am thankfull for your help.
Kind regards
Iris
Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
Re: basic access authentication
Posted: Tue Jul 28, 2020 11:08 PM

This are the credentials, that I have to use:

https://www.korrespondenzmanager.com/be ... /index.php
Benutzer: wusr90174-01
Passwort: twertz34

Thank you for your help
Iris

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: basic access authentication
Posted: Wed Jul 29, 2020 04:18 AM
Doesn't this work?
Code (fw): Select all Collapse
loHyperlink:SetRequestHeader( "Authorization" ,"Basic " + hb_base64encode( "wusr90174-01:twertz34" ) )
Regards



G. N. Rao.

Hyderabad, India
Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
Re: basic access authentication
Posted: Wed Jul 29, 2020 07:32 AM
Dear Mr. Rao,

unfortunately it does not work, but I do not find the error.
I have changed it like this:

Code (fw): Select all Collapse
loHyperlink := CreateObject( 'Microsoft.XMLHTTP' )
loHyperlink:Open( "POST" ,"https://www.korrespondenzmanager.com/betriebe/2710335266647221/index.php", .F. )
loHyperlink:SetRequestHeader( "Authorization" ,"Basic " + hb_base64encode( "wusr90174-01:twertz34" ) )
loHyperlink:Send( cXML )


This is the reponsetext:


Kind regards
Iris
Posts: 38
Joined: Fri Apr 22, 2016 10:19 PM
Re: basic access authentication
Posted: Wed Jul 29, 2020 08:01 AM
Dear Mr. Rao,

it is resolved, thank you very much.
Code (fw): Select all Collapse
cUserPW := hb_base64encode(cHotelCode+":"+cMsgPassword,len(cHotelCode+":"+cMsgPassword))

set date french
set century on


loHyperlink := CreateObject( 'Microsoft.XMLHTTP' )


loHyperlink:Open( "POST" ,"https://www.korrespondenzmanager.com/betriebe/2710335266647221/index.php", .F. )
loHyperlink:SetRequestHeader( "Authorization" ,"Basic " + cUserPW )


loHyperlink:Send( cXML )


Kind regards
Iris
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: basic access authentication
Posted: Wed Jul 29, 2020 03:21 PM

Yes, hb_base64encode() requires length of the string as the second parameter. Sorry I omitted that by mistake.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion