Panel |
---|
title | Configuring OAuth for WSO2 Playground |
---|
|
Before you begin, you must first configure OAuth for a service provider to use this sample. - Add a new service provider.
- Sign in. Enter your username and password to log on to the Management Console.
- Navigate to the Main menu to access the Identity menu. Click Add under Service Providers.
- Fill in the Service Provider Name and provide a brief Description of the service provider. Only Service Provider Name is a required field.
- Click Register to add the new service provider.
Expand the Inbound Authentication Configuration section and configure OAuth/OpenID Connect. Note |
---|
You can use the following Callback URL when configuring OAuth for WSO2 Playground: http://wso2is.local:8080/playground2/oauth2client |
|
Excerpt |
---|
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 tocheckout 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/hosts file of your machine to configure the hostname. Info |
---|
title | 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/host file as explained in this step. The etc/host file 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. Code Block |
---|
sudo nano /etc/hosts |
| Code Block |
---|
language | bash | 127.0.0.1 wso2is.local |
In your command line, navigate to <SAMPLE_HOME>/oauth2/playground2 in the folder you checked out 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). Code Block |
---|
mvn clean install |
After successfully building the sample, a .war file named playground2 can be found inside the <SAMPLE_HOME>/oauth2/playground2/target folder. Deploy this sample web app on a web container. To do this, use the Apache Tomcat server. Note |
---|
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.war file to the <TOMCAT_HOME>/webapps folder. - Start the Apache Tomcat server.
Make sure to update param-value the following parameter in the WEB-INF/web.xml file with the serverurlof server URL of the Identity Server if required. Service URL should have the port the application is started up with. If you have started the Identity Serve with anoff setan offset, then the matching port should be configured here. Code Block |
---|
<init-param>
<description>serverUrl</description>
<param-name>serverUrl</param-name>
<param-value>https://localhost:9443/services/</param-value>
</init-param> |
Info |
---|
Note that localhost is the server that hosts WSO2 Identity Server and 9443 is the default SSL port of it.Inorderto 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, usernameand password asdescripbedin username and password as described in step 5 and 6. |
Update param-value of the parameters below with credentials of an admin user if required. Code Block |
---|
<init-param>
<description>userName</description>
<param-name>userName</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<description>password</description>
<param-name>password</param-name>
<param-value>admin</param-value>
</init-param> |
Update the hostname in etc/hosts to wso2is.local or something similarly appropriate. Restart Apache Tomcat and access http://wso2is.local:8080/playground2/ (assuming Tomcat is running on HTTP port 8080). You are directed to the landing page of the sample application. Click on Import Photos and the following page appears. Image Modified
Note |
---|
Are you getting the error that is given below? Code Block |
---|
| javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target |
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:
...