Page 1 of 1

basic access authentication

Posted: Tue Jul 28, 2020 10:56 pm
by Iris Gesser
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: Select all

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

Re: basic access authentication

Posted: Tue Jul 28, 2020 11:08 pm
by Iris Gesser
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

Re: basic access authentication

Posted: Wed Jul 29, 2020 4:18 am
by nageswaragunupudi
Doesn't this work?

Code: Select all

loHyperlink:SetRequestHeader( "Authorization" ,"Basic " + hb_base64encode( "wusr90174-01:twertz34" ) )

Re: basic access authentication

Posted: Wed Jul 29, 2020 7:32 am
by Iris Gesser
Dear Mr. Rao,

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

Code: Select all

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:
[img]c:\xmm_terminal\LOGO\Clip1.jpg[/img]

Kind regards
Iris

Re: basic access authentication

Posted: Wed Jul 29, 2020 8:01 am
by Iris Gesser
Dear Mr. Rao,

it is resolved, thank you very much.

Code: Select all


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

Re: basic access authentication

Posted: Wed Jul 29, 2020 3:21 pm
by nageswaragunupudi
Yes, hb_base64encode() requires length of the string as the second parameter. Sorry I omitted that by mistake.