I've configured a Named Credential to use the JWT authentication protocol (not JWT Token Exchange), but when the component makes a call to my service using the named credential, I don't get the JWT as an Authorization header. I checked all the headers, and don't see an "Authorization" header at all.
When I change the authentication type to basic or JWT Token Exchange, then it works, sending the values I expect.
Should there be a JWT in the Authorization header?
Do I have my issuer and audience set up correctly? When I experimented with JWT token exchange, it seemed picky about those.
Identity Type: Named Principal
Authentication Protocol: JWT
Issuer: <the host name of my Salesforce instance>.lightning.force.com
Named Principal Subject: <my user name>
Audiences: https://<the base URL of the remote server>
Token Valid for: 10 Seconds
JWT Signing Certificate: My_Sample
Generate Authorization Header: checked
Allow Merge Fields in HTTP Header: checked
Allow Merge Fields in HTTP Body: checked
Outbound Network Connection: blank
My Apex code (actually written by someone else a long time ago), which works for Basic Authentication
HttpRequest request = new HttpRequest(); String statusApi = 'callout:my_named_connection/api/status'; request.setEndpoint(ApiProxy.appendUrlParams(statusApi, request)); request.setMethod('POST'); request.setHeader('Content-Type', 'application/json'); request.setHeader('Content-Length', String.valueof(body.length())); request.setBody(body); request.setTimeout(10000); HttpResponse response = http.send(request);