Page 1 of 1
HTTP POST with user & password combined
Posted: Tue Dec 21, 2021 10:55 pm
by jtaylor
I need to call a web service and the spec says that the user and password must be base64 encoded and sent all together. Their docs say:
This header will consist of three items, the static value “Basic” followed by a base64 encoded string that contains your user name and password separated by a colon
The docs show
Code: Select all
Authorization: Basic VXNlcm5hbWU6UGFzc3dvcmQ=
as an example.
Is there a way to accomplish this with http_url_post() and http_setauth()?
TIA
Re: HTTP POST with user & password combined
Posted: Tue Dec 21, 2021 11:08 pm
by Scott Klement
Code: Select all
http_setAuth(HTTP_AUTH_BASIC: UserID: Password);
Then run http_url_post (or preferably one of the newer routines) and it will use the userid/password you've set.
Re: HTTP POST with user & password combined
Posted: Wed Dec 22, 2021 2:44 pm
by jtaylor
I can do that. I know user/password in POSTMAN doesn't work, and I guessed it was the weird user:password encoded as one string. I assumed that would be an issue in HTTPAPI as well.
Thanks
Re: HTTP POST with user & password combined
Posted: Wed Dec 22, 2021 7:21 pm
by Scott Klement
jtaylor wrote: ↑Wed Dec 22, 2021 2:44 pmI know user/password in POSTMAN doesn't work, and I guessed it was the weird user:password encoded as one string.
Can you explain this better?
The standard for basic authentication is to concatenate the userid and password (with a colon between them) and then base64 encode it. That sounds exactly like what you are describing, right?
This is part of the core HTTP standard, required for all HTTP clients to implement. I know that PostMan does, in fact, work fine with this -- I've used it before. All web browsers support it. SoapUI supports it. Everything does -- it's the most common authentication type out there.
Or, are you saying that instead of user:password you have a string that doesn't contain two separate parts, but has a single string without the colon? That would indeed be weird, and would not be following the HTTP standard. (You can do different authentication types following your own scheme, but you can't refer to them as "basic")
Re: HTTP POST with user & password combined
Posted: Wed Dec 22, 2021 7:46 pm
by jtaylor
I think their documentation is just misleading. It says the username must be upper case, and that you must manually encode the credentials yourself. Both are wrong. I corrected the case in Postman and my RPG code, and both succeed.
Thank you for your help.