Step 4. Test the app
In the following procedure, you run the sample app that you configured in the previous step. The sample connects to your server and walks through the authentication journey you created in an earlier step.
After successful authentication, the sample obtains an OAuth 2.0 access token and displays the related user information.
-
In a terminal window, navigate to the root of your
sdk-sample-apps
project. -
To run the embedded login sample, enter the following:
npm run start:embedded-login
-
In a web browser:
-
Ensure you are NOT currently logged into the server instance.
If you are logged into the PingAM instance in the browser, the sample will not work. Logout of the PingAM instance before you run the sample. -
Navigate to the following URL:
https://localhost:8443
A form appears with "Username" and "Password" fields, as defined by the page node in the
sdkUsernamePasswordJourney
you created in a previous step: -
Authenticate as a non-administrative user, and click Sign In.
Default login credentials:
-
"Username" -
demo
-
"Password" -
Ch4ng3it!
If the app displays the user information, authentication was successful:
To see the application calling the authorize
andauthenticate
endpoints, open the Network tab of your browser’s developer tools.
-
-
-
To revoke the OAuth 2.0 token, click the Sign Out button.
The application calls the
endSession
endpoint to revoke the OAuth 2.0 token, and returns to the sign-in form.
Recap
Congratulations!
You have now used the Ping SDK for JavaScript to authenticate to your server instance.
You have seen how to obtain OAuth 2.0 tokens, view the related user information, and log a user out of the server.