diff --git a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx index d59a893d6b6..228fdf4ff4f 100644 --- a/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx +++ b/portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/AIEndpointAuth.jsx @@ -16,7 +16,7 @@ * under the License. */ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import PropTypes from 'prop-types'; import { isRestricted } from 'AppData/AuthManager'; @@ -33,11 +33,22 @@ export default function AIEndpointAuth(props) { const [apiKeyIdentifier] = useState(apiKeyParamConfig.authHeader || apiKeyParamConfig.authQueryParam); const [apiKeyValue, setApiKeyValue] = - useState(api.endpointConfig?.endpoint_security?.[isProduction ? 'production' : 'sandbox']?.apiKeyValue ? - '***********' : null); + useState(api.endpointConfig?.endpoint_security?.[isProduction ? 'production' : 'sandbox']?.apiKeyValue === '' ? + '********' : null); const [isHeaderParameter] = useState(!!apiKeyParamConfig.authHeader); + useEffect(() => { + saveEndpointSecurityConfig({ + ...CONSTS.DEFAULT_ENDPOINT_SECURITY, + type: 'apikey', + apiKeyIdentifier, + apiKeyValue: api.endpointConfig?.endpoint_security?.[isProduction ? 'production' : 'sandbox']?.apiKeyValue + === '' ? '' : null, + enabled: true, + }, isProduction ? 'production' : 'sandbox'); + }, []); + return ( <>