I am having issue to pass bearer token to target server endpoint.
Could you please provide me an example of how to set Bearer token and pass it to target server endpoint.
I created an Assign message and added the below code
<?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/>
<Set>
<Header name="Authorization">Bearer {"abcdefgh"}</Header>
<Header name="Content-Type">"application/json"</Header>
<!-- <Verb>GET</Verb> -->
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
Assigned this to target endpoint preflow
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>Assign-Message-1</Name>
</Step>
</Request>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows/>
<HTTPTargetConnection>
<URL>my target endpoint url</URL>
</HTTPTargetConnection>
</TargetEndpoint>
Below is the error message I receive when I try to test
{
"ok": false,
"error": "not_authed"
}
Could anyone please help with this @dino-at-google, @Former Community Member
Solved! Go to Solution.
Using a variable you should not use quotes. It also looks like you're missing the <Headers> tag.
So you should set the header as follows:
<Set>
<Headers>
<Header name="Authorization">Bearer {my-token-var}</Header>
</Headers>
</Set>