Nevermind. For anyone else who finds this thread: C_TEXT(URLText_t) C_TEXT(Text_t) URLText_t:="https://langley.herokuapp.com/ppp/201905" C_TEXT(encoded) C_TEXT($user;$pass;$tobeencoded) $user:="Lansterlo" $pass:="Pasturized" $tobeencoded:=$user+":"+$pass TEXT TO BLOB($tobeencoded;$blob_z;UTF8 text without length) BASE64 ENCODE($blob_z;encoded) ARRAY TEXT(HeaderNames_at;1) ARRAY TEXT(HeaderValues_at;1) HeaderNames_at{1}:="Authorization" HeaderValues_at{1}:="Basic "+encoded $httpResponse:=HTTP Get(URLText_t;Text_t;HeaderNames_at;HeaderValues_at)
Text_t contains the response. (BTW, thanks for the quick reply Matt) On Wed, Jul 17, 2019 at 11:19 AM Noah <[email protected]> wrote: > Ha! > Moments after sending, I tried one more thing: > HeaderNames_at{1}:="Authorization" > HeaderValues_at{1}:="Basic TGFuZ2xvOlBhc3R1cml6ZWQ=" > > That worked! > So I guess my question is much simpler. > > How would I manually base64 encode the needed string? > > Many thanks! > > On Wed, Jul 17, 2019 at 11:16 AM Noah <[email protected]> wrote: > >> We have used Basic Auth in other parts of our infrastructure with Great >> success, but have not had the need to pass authentication from 4D, until >> now. >> We are trying to replace a SOAP service with a REST based 'pass through' >> service. >> >> Using HTTPS to protect a basic auth header meets the minimum requirements >> for security. >> >> https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#Basic_authentication_scheme >> >> I have built a prototype web service to handle these requests, and can >> interact with it via "postman" >> >> Here is some generated code from the postman app: >> wget --quiet \ --method GET \ --header 'authorization: Basic >> TGFuZ2xvOlBhc3R1cml6ZWQ=' \ --output-document \ - >> https://prototype.url.com/ppp/201905 >> >> Trying to build this out in 4D, I have the following: >> >> C_TEXT(URLText_t) >> C_TEXT(Text_t) >> URLText_t:="https://prototype.url.com/ppp/201905" >> ARRAY TEXT(HeaderNames_at;2) >> ARRAY TEXT(HeaderValues_at;2) >> HeaderNames_at{1}:="Username" >> HeaderNames_at{2}:="Password" >> HeaderValues_at{1}:="Langlo" >> HeaderValues_at{2}:="Pasturized" >> $httpResponse:=HTTP Get(URLText_t;Text_t;HeaderNames_at;HeaderValues_at) >> >> However, 4D is not generating the correct (base64 encoded) header as it >> initiates the HTTP Get. >> >> >> In other languages (like Javascript) you can generate a base64 encoded >> string like this: >> >> var user = 'user';var password = 'password';var base64encodedData = new >> Buffer(user + ':' + password).toString('base64'); >> >> I have looked at the base64-encode method for 4D, but am not sure how I >> could accomplish the same thing. >> https://doc.4d.com/4Dv16/4D/16.5/BASE64-ENCODE.301-4227612.en.html >> >> Has anyone else already been down this road? >> Any suggestions on passing HTTP auth out of 4D to an external service? >> >> Many thanks, >> Noah >> > ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

