
{"alg":"RS256"}
and encode it using Base64urliss
, sub
, aud
, and exp
and encode it using Base64url{"iss": "<Client_ID>",
"sub": "<my@email.com>",
"aud": "https://login.salesforce.com",
"exp": <expiration time of the assertion within 3 minutes>}
encoded_JWT_Header + "." + encoded_JWT_Claims_Set
encoded_JWT_Header + "." + encoded_JWT_Claims_Set + "." + base64_encoded_signature
https://login.salesforce.com/services/oauth2/token
with below parametersStep Type | Name | Description |
Content Modifier | setHeader | Set Message Body to {"alg":"RS256"} ![]() |
Script | b64URL1 | Base64 URL Encode JWT header |
Script | setReqProperty |
|
Content Modifier | setClaimSet |
![]()
![]() |
Script | b64URL2 | Base64 URL Encode the JWT claimset |
Content Modifier | constructToken | Append JWT Header and JWT Claimset with .(dot) delimiter ![]() Note: All steps until here (6 totally) can be combined in to one using Groovy Script. For demonstration I have used standard step types. |
Signer | SimpleSigner |
![]() |
Script | b64URL3 | Make the Signature value in header URL safe using string replace operation. |
Content Modifier | appendSignature |
![]()
![]() |
Content Modifier | DeleteHeader | Remove all headers except content-type. ![]() |
Request Reply | callAuthServer | Invoke Salesforce token endpoint. ![]() Upon successful JWT validation salesforce return bearer access token.
|
Script | extractToken | Parse JSON Response and extract access token and instance URL |
Write Variable | saveToken | Save access token, instance URL and timestamp in global variable ![]() |
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import org.apache.commons.codec.binary.Base64;
def Message processData(Message message) {
def body = message.getBody();
message.setBody(Base64.encodeBase64URLSafeString(body.getBytes("UTF-8")));
return message;
}
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.Date;
import com.sap.it.api.ITApiFactory;
import com.sap.it.api.securestore.SecureStoreService;
import com.sap.it.api.securestore.UserCredential;
def Message processData(Message message) {
//Set expiry time property value
Date d = new Date();
message.setProperty("expTime",((d.getTime() / 1000) + 180).intValue());
//Read SFDC connected APP client ID
def service = ITApiFactory.getApi(SecureStoreService.class, null);
def credential = service.getUserCredential("SFDCClientCred");
String clientID = credential.getUsername();
//Store client ID as property
message.setProperty("clientID", clientID);
return message;
}
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
//Get Signature value from header
map = message.getHeaders();
signedContent = map.get("JWTSignatureValue");
//Replace characters to make it URL safe
signedContent = signedContent.replaceAll("\n","").replaceAll("\\+","-").replaceAll("/", "_").replaceAll("\\=","");
//Set URL safe Signature in header
message.setHeader("JWTSignatureValue", signedContent);
return message;
}
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.json.*
def Message processData(Message message) {
//Get Response Payload
def body = message.getBody(String.class);
//Parse JSON Payload
def jsonSlurper = new JsonSlurper()
def list = jsonSlurper.parseText(body)
//Retrieve required values and store it in property
message.setProperty("accesstkn",list.access_token.toString());
message.setProperty("insURL",list.instance_url.toString());
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |