I'm trying to create a test stream like this : time | oauth-processor | httpclient | log
.
In this stream, my oauth-processor gets a token and store it in the kafka message headers. This one works well and I get a message like :
[
payload=03/19/21 13:00:15,
headers={
... standard-headers ...,
...
OAuth={
TokenType=bearer,
ExpiresIn=480,
AccessToken=myEncodedToken
}
}
]
Then I want to put the token in the HTTP header for authentication like this :
{
'Content-Type':'application/json',
'Authorization':'bearer myEncodedToken'
}
Here is what I'm trying with the header-expression property in command line :
--headers-expression={'Content-Type':'application/json', 'Authorization':#jsonPath(headers, \"$.OAuth.TokenType\").concat(\" \").concat(#jsonPath(headers, \"$.OAuth.AccessToken\"))}
but I can't manage to create a valid JSON string with SpEL.
The documentation for starter apps is very poor, as for SpEL in SCDF
(especially when we have to escape characters) and I can't find anything helpful on the Internet
I would really appreciate any help. Thanks
I find a solution using a properties file with this line :
app.httpclient.headers-expression={'Content-Type':'application/json','Authorization' : headers.OAuth.Authorization}
SpEL is very confusing in SCDF...
Sometimes you need to use #jsonPath, sometimes not ...
Not sure but it seems that the comma was also breaking the expression in the command line