-2

The Basic authentication information that I currently set in the Http Request Module of Anypoint Studio is as shown in the attached image. (The username and password information is described as it is in the property file.)

enter image description here

What I want to achieve is an image in which the value of the Authorization header is base64-encoded with username: password as the basic authentication setting value. I would like to realize the following image with the HTTP Request module. Is it possible? If it is possible, please teach me the detailed implementation method.

Authoraization: Basic [base64 encoded username:password]

  • Username and password will be constant for ever? – Chris P Jul 16 '22 at 08:08
  • I don't know for this language specific but if will be one time you can use for example python: https://ao.ms/how-to-base64-encode-a-string-in-python/ – Chris P Jul 16 '22 at 08:10
  • 1
    Crarify what you mean by: you 'want to achieve an image'. To me an image is a png or a jpg in binary format. And it does not have an Auth header. – HEllRZA Jul 16 '22 at 08:14
  • Please [don’t post images of code. error messages, or other textual data.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) – tripleee Jul 16 '22 at 08:29
  • What do you mean by image? – Harshank Bansal Jul 16 '22 at 10:49

1 Answers1

0

The HTTP Requester supports using HTTP Basic Authorization directly, without needing to manually encode the values.

Example:

    <http:request-config name="HTTP_Request_configuration" >
        <http:request-connection protocol="HTTP" host="myhost.com" port="80" >
            <http:authentication >
                <http:basic-authentication username="secretuser" password="12345678" />
            </http:authentication>
        </http:request-connection>
    </http:request-config>

See the documentation for details.

aled
  • 21,330
  • 3
  • 27
  • 34