Skip to main content

Posts

Showing posts with the label Spring

2 Legged OAuth 1.0 with Java Spring REST Client Example

Today I am going to show you how to consume an oAuth 1.0 secured rest service using a java spring rest template class. We can create a simple standalone class to do this exercise.  so let's start by creating simple java spring application. 1. Let's add a new class to the project as MyOAuthSample.java 2. Create a main method so we can execute the application independently. In the main method we will create an instance of MyOAuthSample class and call the showCourseMode() method.     public static void main(String[] args) {         new MyOAuthSample().showCourseMode();     } 3. Write showCourseMode() method. here we will be using spring provided  OAuthRestTemplate class to call the rest service. This template requires OAuth parameters to create. they are passed via getResouces().     private void showCourseMode() {         OAuthRestTemplate authRestTemplate=n...