Hello All,
I am new to apigee, please pardon my ignorance My target endpoint requires username/password, so I wanted to hardcode the credentials, for this I created first a "KVM" .. Then I created the "Basic Authentication policy.. But when I use it I get following error
{ fault: { faultstring: "Unresolved variable : CRAuthMap.cr.username", detail: { errorcode: "steps.basicauthentication.UnresolvedVariable" } } }
Following is my KVM
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="CreateCRAuthMap"> <DisplayName>CreateCRAuthMap</DisplayName> <Properties/> <ExpiryTimeInSecs>86400</ExpiryTimeInSecs> <Put> <Key> <Parameter>cr_username</Parameter> </Key> <Value>content-repo-reader</Value> </Put> <Put> <Key> <Parameter>cr_password</Parameter> </Key> <Value>XXXXXXX</Value> </Put> <Scope>environment</Scope> </KeyValueMapOperations>
Following is my auth policy
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <BasicAuthentication async="false" continueOnError="false" enabled="true" name="Basic-Authentication-1"> <DisplayName>CR Authentication</DisplayName> <Operation>Encode</Operation> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <User ref="CRAuthMap.cr.username"/> <Password ref="CRAuthMap.cr.password"/> <AssignTo createNew="false">request.header.Authorization</AssignTo> <Source>request.header.Authorization</Source> </BasicAuthentication>
Solved! Go to Solution.
Welcome to the community !!
There was a similar post - please refer to this answer and let us know if you are still stuck
Welcome to the community !!
There was a similar post - please refer to this answer and let us know if you are still stuck
Thank you, butI followed the same steps and I get
{ fault: { faultstring: "Unresolved variable : cr.username", detail: { errorcode: "steps.basicauthentication.UnresolvedVariable" } } }
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="CR-Get-User-Crendentials" mapIdentifier="CRCredentials"> <DisplayName>CR-Get-User-Crendentials</DisplayName> <Properties/> <ExclusiveCache>false</ExclusiveCache> <ExpiryTimeInSecs>300</ExpiryTimeInSecs> <Get assignTo="cr.username" index="1"> <Key> <Parameter>username</Parameter> </Key> </Get> <Get assignTo="cr.password" index="1"> <Key> <Parameter>password</Parameter> </Key> </Get> <Scope>environment</Scope> </KeyValueMapOperations>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <BasicAuthentication async="false" continueOnError="false" enabled="true" name="CR-Authentication"> <DisplayName>CR Authentication</DisplayName> <Operation>Encode</Operation> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <User ref="cr.username"/> <Password ref="cr.password"/> <AssignTo createNew="false">request.header.Authorization</AssignTo> <Source>request.header.Authorization</Source> </BasicAuthentication>
KVM policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <KeyValueMapOperations async="false" continueOnError="false" enabled="true" name="CR-Get-User-Crendentials" mapIdentifier="CRCredentials"> <DisplayName>CR-Get-User-Crendentials</DisplayName> <Properties/> <ExclusiveCache>false</ExclusiveCache> <ExpiryTimeInSecs>300</ExpiryTimeInSecs> <Get assignTo="private.cr.username" index="1"> <Key> <Parameter>username</Parameter> </Key> </Get> <Get assignTo="private.cr.password" index="1"> <Key> <Parameter>password</Parameter> </Key> </Get> <Scope>environment</Scope> </KeyValueMapOperations>
Basic Auth policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <BasicAuthentication async="false" continueOnError="false" enabled="true" name="CR-Authentication"> <DisplayName>CR Authentication</DisplayName> <Operation>Encode</Operation> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <User ref="private.cr.username"/> <Password ref="private.cr.password"/> <AssignTo createNew="false">request.header.Authorization</AssignTo> </BasicAuthentication>
Yup that is the issue. my creds are encoded and I did not add the "private". Thanks for the hep.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |