Hi,
I am new to Apigee. I am trying to pass basic authorization userid and password in the header.
I need to pass it to target server though I do not want to accept it from users. I want to hardcode it in the Assign message policy.
Where should I add the assign message policy for the header? Below is my code in assign message:
AM-auth-code
Basic encodeduserid:password value
true
Can you please suggest what am I missing here?
How can I check if the correct header is being passed to the call? Is there place I can see all the headers?
Hi Mugdha,
You can add the assignmessage policy to your target endpoint’s request preflow.
A good practice is to have the basic auth credentials stored in an encrypted KVM and retrieve the value using the KVM-Operations policy with a fetch operation.
Secondly, you can also use a Basic Authentication policy with the encode operation to set the base64 encoded value into the header without the use of assign message policy.
You can refer to the samples at - https://docs.apigee.com/api-platform/reference/policies/basic-authentication-policy#samples
1 Like
You can set the headers in assign message policy and configure this anywhere in the request flow that is the request of preflow, request of post flow of either proxy endpoint, or target endpoint. You can see the headers immediately after the policy in the trace. But I would suggest seeing the curl request details just before the request to the target server.
I see you are using lower case header tag
Basic encodeduserid:password value
and you should use Header in the upper case.
By default your Authorization header value will be seen as ***** in trace and I would suggest to put the confidential information in encrypted KVM or private.varibalename in the flow.
1 Like
hi Priyadarshi,
When I changed header to Header it helped me to see the header that I was not able to see.
It was helpful. Thank you.
Thanks,
Mugdha
Thank you Nagashree. It was helpful.
@Priyadarshi Ajitav Jena hello dear ,
Iam facing the same issue and im new to apigee , can you please help me how to add authntication header to the target step by step .
@Suboh, you need to create one assign message policy. In the set section will be there.
Replace that to
Basic encodeduserid:password value
Encoded userid and password will be of base64 encoding.
Assign the policy to target endpoint preflow request.
1 Like