To obtain and configure the Playground sample, follow the steps below.
You can check out the repository of the OAuth 2.0 sample from GitHub. Follow the instructions here to checkout the folder. We refer
<SAMPLE_HOME>as the modules/samples folder inside the folder where the product-is repository is checked out.
Open a terminal window and add the following entry to the
/etc/hostsfile of your machine to configure the hostname.
Why is this step needed?
Some browsers do not allow you to create cookies for a naked hostname, such as
localhost. Cookies are required when working with SSO. Therefore, to ensure that the SSO capabilities work as expected in this tutorial, you need to configure the
etc/hostfile as explained in this step.
etc/hostfile is a read-only file. Therefore, you won't be able to edit it by opening the file via a text editor. To avoid this, edit the file using the terminal commands.
For example, use the following command if you are working on a Mac/Linux environment.
<SAMPLE_HOME>/oauth2/playground2directory via the terminal and build the sample using the following command. You must have Apache Maven installed to do this (see Installation Prerequisites for the appropriate version to use).
After successfully building the sample, a .
warfile named playground2 can be found inside the
<SAMPLE_HOME>/oauth2/playground2/targetfolder. Deploy this sample web app on a web container, such as Apache Tomcat server.
Since this sample is written based on Servlet 3.0 it needs to be deployed on Tomcat 7.x.
Use the following steps to deploy the web app in the web container:
- Stop the Apache Tomcat server if it is already running.
- Copy the
playground2.warfile to the
- Start the Apache Tomcat server.
Make sure to update
param-valueparameter in the
WEB-INF/web.xmlfile with the server URL of the Identity Server if required.
Make sure to enter the port the application is running on, in the URL. If you have started the Identity Server with a port offset, then the respective port needs to be configured here.
Note that localhost is the server that hosts WSO2 Identity Server and 9443 is the default SSL port of it. In order to access the admin services you should have the values in step 5 and 6. Since playground application is accessing the admin service OAuth2TokenValidationService, you should have the correct serverUrl,username and password as described in step 5 and 6.
param-valueparameter with credentials of an admin user if required.
Restart Apache Tomcat and access
By default Tomcat runs on port 8080. If you have configured it to run on a different port make sure to update the URL and access the playground application.
You are directed to the landing page of the sample application. Click on Import Photos and the following page appears.
Are you getting the error that is given below?
The sample applications do not have a keystore in them. Therefore, after changing the tomcat hostname you might get this error because the public key of the WSO2 Identity Server does not exist in the Java certificate store. For more information on the steps you need to follow to overcome the error, see FAQ.
This application is used to request access tokens using the four OAuth2 grant types: