Hello,
I'm quite new at Apigee. I'm trying to define credentials for a SOAP-based API proxy. What I've done so far is adding a policy "ApplyBasicAuth" to the request and hardcoded the username / password, but I get an error. Is it because there is no way to test with hardcoded credentials? or am I missing something?
Solved! Go to Solution.
The error message states that the required 'ref' attribute is missing in the User element.
Usually the credentials are read from a KVM or header variables and the variables are referenced in the User and Password elements through the "ref" atrtibute.
To try the hardcoded values, add an Assignmessage policy before the BasicAuth, assign the values to two variables and then add the variable names to the ref element
The Basic Auth policy below is expecting the values to be in the variables named uservar and passwordvar
<!-- Assign Message--> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1"> <DisplayName>Assign Message-1</DisplayName> <Properties/> <AssignVariable> <Name>uservar</Name> <Value>test</Value> <Ref/> </AssignVariable> <AssignVariable> <Name>passwordvar</Name> <Value>test</Value> <Ref/> </AssignVariable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage> <!-- Basic Auth --> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <BasicAuthentication async="false" continueOnError="false" enabled="true" name="Basic-Authentication-1"> <DisplayName>Basic Authentication-1</DisplayName> <Operation>Encode</Operation> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <User ref="uservar"></User> <Password ref="passwordvar"></Password> <AssignTo createNew="false">request.header.Authorization</AssignTo> <Source>request.header.Authorization</Source> </BasicAuthentication>
You can refer to the docs for BasicAuth policy -
https://docs.apigee.com/api-platform/reference/policies/basic-authentication-policy#userelement
The error message states that the required 'ref' attribute is missing in the User element.
Usually the credentials are read from a KVM or header variables and the variables are referenced in the User and Password elements through the "ref" atrtibute.
To try the hardcoded values, add an Assignmessage policy before the BasicAuth, assign the values to two variables and then add the variable names to the ref element
The Basic Auth policy below is expecting the values to be in the variables named uservar and passwordvar
<!-- Assign Message--> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Message-1"> <DisplayName>Assign Message-1</DisplayName> <Properties/> <AssignVariable> <Name>uservar</Name> <Value>test</Value> <Ref/> </AssignVariable> <AssignVariable> <Name>passwordvar</Name> <Value>test</Value> <Ref/> </AssignVariable> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <AssignTo createNew="false" transport="http" type="request"/> </AssignMessage> <!-- Basic Auth --> <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <BasicAuthentication async="false" continueOnError="false" enabled="true" name="Basic-Authentication-1"> <DisplayName>Basic Authentication-1</DisplayName> <Operation>Encode</Operation> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <User ref="uservar"></User> <Password ref="passwordvar"></Password> <AssignTo createNew="false">request.header.Authorization</AssignTo> <Source>request.header.Authorization</Source> </BasicAuthentication>
You can refer to the docs for BasicAuth policy -
https://docs.apigee.com/api-platform/reference/policies/basic-authentication-policy#userelement
User | Count |
---|---|
7 | |
2 | |
2 | |
2 | |
1 |