Monday, June 20, 2016

Adding API name to JWT Token WSO2 API Manager 1.8.0

If we need to set additional claims to the JWT token, we need to implement a custom JWT token generator as explained in [1].  Assume you need to set the API Name to the JWT token. You could do it as below in your custom JWT Token generator.

public Map<String, String> populateCustomClaims(APIKeyValidationInfoDTO keyValidationInfoDTO, String apiContext, String version, String accessToken)
            throws APIManagementException {

        String apiName = keyValidationInfoDTO.getApiName();
        Map<String,String> map = new HashMap<String, String>();
        map.put("API_NAME", apiName);

        return map;

This will set the API_NAME property with the value to the JWT token like below.



No comments:

Post a Comment