Configure a Single-Page Application with PKCE and an AuthCode Grant
Number of APIs: 9
This activity shows you how to create an single-page application, configure its connection settings to use Proof Key for Code Exchange (PKCE) parameters in the authorization request for the authorization code grant, and initiate an authorization request.
The following operations are supported by the PingOne APIs:
- Create an application
- Create a user
- Initiate an authorization code flow and use PKCE to authenticate the token request
Prerequisites
Get an access token from the worker application that you created in Getting Started with the PingOne APIs. To get a token from a different worker application in an alternate sandbox environment, run the token request endpoint using the client ID and client secret of your chosen worker app to authenticate the request. For more information, see GET a Worker Application Access Token.
Workflow order of operations
To configure a single-page application and initiate an authentication flow, the following tasks must be completed successfully:
Make a
POSTrequest to/environments/{{envID}}/applicationsto add a new application to the specified environment.Make a
POSTrequest to/environments/{{envID}}/populationsto create a new population resource.Make a
POSTrequest to/environments/{{envID}}/usersto create a user who will be assigned to the new population resource.Make a
POSTrequest to/environments/{{envID}}/users/{{userID}}/passwordto set the new user's password.Make a
POSTrequest to/{{envID}}/as/authorizeto obtain an authorization grant. This request starts the authorization flow.To initiate the authentication flow, make a
GETrequest toGET /{{envID}}/flows/{{flowID}}.To complete the authentication flow, make a
POSTrequest toGET /{{envID}}/flows/{{flowID}}and provide the user's login credentials.Make a
GETrequest to/{{envID}}/as/resume?flowId={{flowID}}to call the resume endpoint and return the token.Make a
POSTrequest to/{{envID}}/as/tokento exchange the auth code for an access token.
-
Step 1: Create a single-page application POST {{apiPath}}/environments/{{envID}}/applications
-
Step 4: Set user password PUT {{apiPath}}/environments/{{envID}}/users/{{appUserID}}/password
-
Step 7: Submit Login Credentials POST {{authPath}}/{{envID}}/flows/{{flowID}}
-
Step 5: Send the authorize request GET {{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{SPAppWithAuthCodeGrantID}}&redirect_uri=https://example.com&scope=openid&code_challenge={{code_challenge}}&code_challenge_method=S256
-
Step 6: Get the Flow GET {{authPath}}/{{envID}}/flows/{{flowID}}
-
Step 8: Call the resume endpoint GET {{authPath}}/{{envID}}/as/resume?flowId={{flowID}}
-
Step 9: Get the access token POST {{authPath}}/{{envID}}/as/token
-
Step 3: Create user POST {{apiPath}}/environments/{{envID}}/users
-
Step 2: Create a population POST {{apiPath}}/environments/{{envID}}/populations