OAuth core specification supports the following four grant types:
- Authorization Code Grant (authorization_code)
- Implicit Grant
- Resource Owner Password Credentials Grant (password)
- Client Credentials Grant (client_credentials)
First you need to setup the sample web app. You can download it here and host it in Tomcat. This can be found at
http://localhost:8080/playground. If the Identity Server is not running on 9443 - then you need to edit the web.xml of the web app appropriately. Click here to download the WSO2 Identity Server.
- Start the WSO2 Identity Server.
- Sign in by entering your username and password to log on to the Management Console.
- Click the Main button to access the Manage menu and select OAuth.
- Click on the Register New Application link on the OAuth Management page.
- Select OAuth 2.0 as the OAuth Version.
- Provide an Application Name and any Callback Url. For the sample to work, use
http://localhost:8080/playground/oauth2client. Here you can select allowed grant types (By default all grant types are activated).
- Once you click Add you are taken to the OAuth Management page once again.
- Click on the application you just created.
- Copy the values of Client ID, Client Secret, Access Token URL and Authorize URL -- you may need these values later during different stages in the web app.
- Once this is done, use the following link to navigate to the web app:
- In the playground, click on Import Photos.
- Execute the OAuth flow by selecting the Grant Type you want.
- Click Authorize.
- WSO2 Identity Server requests access to myscope. Login using your credentials.
- To obtain an access token, enter the value for the Access Token Endpoint and Client Secret and click Get Access Token.
- Click Get Photos.
You can download the complete code of sample web application from here.
From the root level type "
mvn clean install" to build it.