Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can I set the Authorization header?

Not applicable

I'm trying to use @Dino's https://github.com/apigee/iloveapis2015-jwt-jwe-jws/blob/master/jwt_signed to set a JWT token when calling out a service. I tried the below two approaches but I don't see the Authorization header at all in the raw request logs of the receiving service. How can I set the jwt_jwt variable value into the Authorization header?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="Assign-Jwt-Token">
    <DisplayName>Assign Jwt Token</DisplayName>
    <Properties/>
    <Add>
        <Headers>
            <Header name="Authorization">{jwt_jwt}</Header>
        </Headers>
        <QueryParams/>
        <FormParams/>
    </Add>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="Set-JWT-Token-Header">
    <DisplayName>Set JWT Token Header</DisplayName>
    <Properties/>
    <ResourceURL>jsc://SetJwtTokenHeader.js</ResourceURL>
</Javascript>

SetJwtTokenHeader.js:

var jwtToken = context.getVariable("jwt_jwt");
context.setVariable("request.header.Authorization", jwtToken);
0 3 8,265
3 REPLIES 3
Top Solution Authors