import groovy.json.JsonSlurper;
import org.apache.commons.codec.binary.Base64

def authzHeaderValue=requestHeaderMapToTargetAPI.get("Authorization");
authzHeaderValue = authzHeaderValue.split('\\.')[1];
//Bearer part is not exclusively trimmed out since the payload is after first dot.
def decodedValue = new String(Base64.decodeBase64(authzHeaderValue),"UTF-8")

def jsonSlurper = new JsonSlurper();
def jsonMessage = jsonSlurper.parseText(decodedValue);
//do some logic with json:

requestHeaderMapToTargetAPI.put("usernameTest",jsonMessage.username);   
CODE