Search code examples
wso2basic-authenticationwso2-api-manager

Expose API with Basic Authentication in WSO2 API Manager 4.1.0 - Dynamic Authentication


There is a WSO2 EI backend running with Basic Auth mechanism.

Postman - WSO2 EI URL Hit:

WSO2 EI Backend

  • Hosted this backend url in WSO2 API Manager 4.1.0 with Basic Auth mechanism rather than OAuth
  • But this dynamic basic auth is not working, getting 401 unauthorized ERROR as per below postman hit.

Postman - APIM URL Hit:

wso2 apim hit

WSO2 APIM Publisher:

Publisher

WSO2 APIM Dev Portal:

subscription

TryitTool in DEV Portal:

TryOutTool

Scenario:

Real scenario

  • As per above diagram, Client will send Request to WSO2 APIM Url with Basic Auth credentials which needs to be forwarded to backend url instead of setting static value in Endpoint Security Configurations of Publisher portal.

Note: Basic Auth credentials (admin:admin) is passed in each api hit

Reference link

Am I missing anything? How can we achieve this?


Solution

  • The API Gateway drops the authentication header and that’s why you get 401. You can set the EI credentials at the endpoint credentials so that authentication header is passed to the backend. Go to the endpoint section at the APIM and provide the same credentials as the endpoint credentials.

    Although your EI endpoint is secured with basic authentication, you don’t need to expose the API at the gateway with basic authentication. You can use OAuth or API keys.