Skip to main content

Posts

Showing posts from February, 2015

Retrieving OAM OAuth access token through Java

Create a OAuth client in OAM. Encode the username and password of the client in "username:password" format. This can be achieved from https://www.base64encode.org/ site. Once OAuth client is created it can be checked using below command: curl -i -H 'Authorization: Basic <Encoded Username:Password>' -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" --request POST http://<OAM_host>:14100/ms_oauth/oauth2/endpoints/oauthservice/tokens -d 'grant_type=password&username=<OAM_Admin>&password=<OAM_Admin_Pwd>'   If the response is 200 and access token is retrieved then OAuth service is working fine. Same access token can be retrieved using below sample code : import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStreamReader; import org.json.JSONObject; import java.net.HttpURLConnection; import java.net.URL; public class CheckRest { public static void main(Stri