I develop an Apex class wich calls an web service from another system.

I need to use a JWT to make the authentication but I never used it, so I don't know how to do it.

I read the Salesforce documentation but I am not sure to understand what I esactly have to do.

Do you have an article which deals about it?



1 Answer 1


Just set the header with JWT when calling the web API. Here's some sample code that uses JWT in a http request.

HttpRequest req = new HttpRequest(); 
req.setHeader('Authorization', 'Bearer ' + token);

Http http = new Http();
HttpResponse res = http.send(req); 
Map<String, Object> response;

if (res.getStatusCode() == 200 ) { 
  response = (Map<String, Object>)JSON.deserializeUntyped(res.getBody()); 
  System.debug('response: ' + response);
else {

Not the answer you're looking for? Browse other questions tagged .