FoxPro Programming
Base64 encoded credentials
Gravatar is a globally recognized avatar based on your email address. Base64 encoded credentials
  JohnB
  All
  Nov 10, 2017 @ 09:59am

I am trying to do a simple httpget request:

``parameters pcrequest

lohttp = createobject('wwHttp')

loHttp.AddPostKey(pcrequest)

lcresult = lohttp.httpget(lcurl,lcuser,lcpassword)``

and the requirement is that credentials are base64 encoded. What is the way to do that?

I was told to encrypt in the format "username:password"

John

Gravatar is a globally recognized avatar based on your email address. re: Base64 encoded credentials
  Rick Strahl
  JohnB
  Nov 10, 2017 @ 10:56am

Easy - it's built in:

lcValue = "1234ABC"
lcBase64 = STRCONVERT(lcValue,13)

But - if this is using Basic Authentication (which it looks like it is) the encoding happens automatically by the client when providing the credentials. IOW - don't encode the value yourself, WinInet will do that for you.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Base64 encoded credentials
  JohnB
  Rick Strahl
  Nov 10, 2017 @ 11:19am

Without trying to encode the credentials, I sent the message and I got a response which did not indicate anything about base64. The message sent and received are:

Sent: GET /api/v5/transactions?merchantId=ANV&clientSystemTransactionId=AC=21001WVD:CC=21010XZ

Received:

{"code":"4000340","details":{"message":"Type is required"}}

The fact that I got a response indicated to me that the credentials are ok.
The vendor said he tried my request on his side and it was successful and asked about the base64 encoding... maybe a red herring.

Gravatar is a globally recognized avatar based on your email address. re: Base64 encoded credentials
  JohnB
  JohnB
  Nov 10, 2017 @ 11:54am

Hi Rick,

The problem had nothing to do with base64 encoding in the end. It was a simple case of correcting the url.

Sorry to bother you on this one.

John

© 1996-2024