OAuth – Grant Type Client Credentials

If Grant Type is set as Client Credentials, you have to pass IAM API key/Secret key as client Id and Secret key to get the access token. This can be done through any OAuth client library or you can also make a direct REST call to following URL to get the access token. Below is the Java snippet of OAuth client to fetch access token

String clientId = “xxxxxx”; //Pass APIKey of IAM here String clientSecret = “xxxxxx”; // PAss Secret Key of IAM here String tokenEndPoint = “http://$GATEWAYURL/api/$VERSION/$APINAME/token”; OAuthClientRequest request = OAuthClientRequest.tokenLocation(tokenEndPoint).setClientId(clientId) .setClientSecret(clientSecret).setGrantType(GrantType.CLIENT_CREDENTIALS) .buildQueryMessage(); OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient()); OAuthJSONAccessTokenResponse response = oAuthClient.accessToken(request); System.out.println(response.getBody());

Once you got the access token, you can pass this in your API call to App42 API gateway for authentication. API gateway will do all the validation and authentication on it and allow the API call if it is valid access token.