Test the Python Application

In this section of the solution, you register the sample Python web application to integrate it with Oracle Identity Cloud Service for authentication purposes, set up the application to make it use Oracle Identity Cloud Service’s SDK for Python, and prepare, run, and test the application.

Register the Python Application

To establish communication with Oracle Identity Cloud Service, the sample web application needs a client ID and client secret. You also need to configure API permissions to grant to the sample web application.

To register the sample web application with Oracle Identity Cloud Service:

  1. In the Identity Cloud Service console, expand the Navigation Drawer, click Applications.
  2. In the Applications page, click Add.
  3. In the Add Application chooser dialog, click Trusted Application.
  4. In the Name and Description fields of the Details pane, enter SDK Web Application, and then click Next.
  5. In the Client pane, select Configure this application as a client now, and then populate the fields of this pane, as follows:

    Table - Client pane

    Field Value
    Allowed Grant Types Select Client Credentials and Authorization Code.
    Allow non-HTTPS URLs Select this check box. The sample application works in non-HTTPS mode.
    Redirect URL http://localhost:8000/callback
    Logout URL http://localhost:8000/logout
    Post Logout Redirect URL http://localhost:8000
  6. In the Client pane, scroll down, select Grant the client access to Identity Cloud Service Admin APIs., enter Me in the field below, and then click Next.
  7. On the following panes, click Next until you reach the last pane. Then, click Finish.
  8. In the Application Added dialog box, make a note of the Client ID and Client Secret values, and then click Close. Your web application needs these values to integrate with Oracle Identity Cloud Service.
  9. To activate the application, click Activate.
  10. In the Activate Application? dialog box, click Activate Application.

    The success message The SDK Web Application application has been activated. appears.

  11. In the Identity Cloud Service console, click the user name at the top-right of the screen, and click Sign Out.

Set up the Python Application

To set up the sample application code to make it use Oracle Identity Cloud Service's SDK for Python programming language:

  1. Update the c:\temp\python\config.json file with the following content:
    {
     "ClientId" : "123456789abcdefghij", 
     "ClientSecret" : "abcde-12345-zyxvu-98765-qwerty", 
     "BaseUrl" : "https://idcs-abcd1234.identity.oraclecloud.com", 
     "AudienceServiceUrl" : "https://idcs-abcd1234.identity.oraclecloud.com",
      "scope" : "urn:opc:idm:t.user.me openid",
      "TokenIssuer" : "https://identity.oraclecloud.com",
      "redirectURL": "http://localhost:8000/callback",
      "logoutSufix":"/oauth2/v1/userlogout"
    }
  2. Save the config.json file.

Run the Python Application

To prepare, run, and test the sample web application:

  1. Open a command prompt and navigate to the c:\temp\python folder.
  2. At the command prompt, enter python.exe manage.py migrate to prepare the sample application, and then run the command line python manage.py runserver to start it.

    The python server uses the 8000 port. Make sure that the port is not in use by another service.

  3. Open a browser window, access the http://localhost:8000 URL, and click Log in.
  4. In the Login page, click the Oracle red icon, which appears to the right of or You can log in with.

    The sample application's login form (the Email and Password fields, and the Log In button) doesn’t work. It’s illustrative only.

  5. In the Oracle Identity Cloud Service Sign In page, sign in using your Oracle Identity Cloud Service credentials.

    After you sign in to Oracle Identity Cloud Service successfully, the browser is redirected to the /home page. The name of the logged-in user appears at the top right.

  6. In the left menu, click My Profile.
  7. Verify that information associated with your profile appears in the center of the page.