Monday, November 5, 2012

OAuth 1.0 Playground with Wso2IS 4.0.0

Following Playground 1.0 application is written for Oauth 1.0
First you have to download the Oauth Playground 1.0 war and deploy on the Apache tomcat server

Then you have to open the playground.war file and go to /WEB-INF/web.xml file
Find WSO2CARBON_URL parameter and replace the parameter value with your absolute path of wso2carbon.jks file.
ex/ You can easily find wso2carbon.jks form $IS_HOME/repository/resources/security/

[sourcecode language="xml"]
<init-param>
<description>Wso2Carbon.jks file location</description>
<param-name>WSO2CARBON_URL</param-name>
<param-value>$IS_HOME/repository/resources/security/wso2carbon.jks</param-value>
</init-param>
[/sourcecode]

Once you finish this save the web.xml file.
Now you can verify the application from http://localhost:8080/playground/
Download source code of Playground 1.0



Now you have to start the IS and register the Oauth application as follows go to "Manage -> OAuth"
Oauth version - 1.0
Application Name - playground
Callback Url - http://localhost:8080/playground/oauth/oauth_callback



Click on the registered application you can see the following window with all the details



Now go to application playground http://localhost:8080/playground/ and fill the details
Consumer key, Consumer Secret you can take those form the IS
Scope you can give as a String ex/ echoService



Once you send this you get the oauth_token  and oauth_token_secret



Now you have to send the oauth_token to Authorize



After Authorizing the Token IS will send you the Access_token



Now you can access the resource form the given token



This is a test application so what we are doing is just take the toke and if its is ok then the application will print the Authorized user and the scope in the back end. you can see the following out put in the tomcat server console once you click on the "Access Service"

3 comments:

  1. In this playground pom file .. you could improve the hard corded systemPath values ${basedir}
    for example : ${basedir}/src/main/webapp/WEB-INF/lib/org.wso2.carbon.identity.oauth.stub-4.0.3.jar

    ReplyDelete
  2. Thanks Ramith. POM file updated with ${project.basedir}

    ReplyDelete