For web applications, the typical grant type to request access to protected resources is authorization_code
. The /{{envID}}/as/authorize
endpoint supports GET
and POST
methods and returns the authorization code needed to acquire an access token. After an authorization code is returned successfully, the code is used to get the access token.
The following sample shows the GET /{{envID}}/as/authorize
operation.
https://auth.pingone.com/{{envID}}/as/authorize?response_type=code&client_id={{appID}}&redirect_uri={{redirect_uri}}&scope=openid%20profile%20email&acr_values=Single_Factor&prompt=login
The request URL contains the following parameter values:
response type
Specifies the response type for the authorization request. If the grant type is authorization_code
, the response_type
parameter must have a value of code
. This parameter is required.
client_id
Specifies the application’s UUID, returned from a GET /environments/{{envID}}/applications/{{appID}}
request. This parameter is required.
redirect_uri
Provides a URL that specifies the return entry point of the application. This parameter is required.
Note: To ensure proper redirect on some iOS and OSX browsers, the redirect_uri
value must include a trailing slash. For example, a registered URI of https://www.pingidentity.com/
redirects properly to https://www.pingidentity.com/#access_token=eyJsdf
, but a registered URI of https://www.pingidentity.com
redirects incorrectly to https://www.pingidentity.com/en.html, and the client application would not receive the access token.
scope
Specifies permissions that determine the resources that the application can access. This parameter is not required, but it is needed to specify accessible resources.
acr_values
An optional parameter that designates whether the authentication request includes specified sign-on policies. Sign-on policy names should be listed in order of preference, and they must be assigned to the application. For more information, see Sign-on policies.
prompt
An optional parameter that specifies whether the user is prompted to login for re-authentication. The prompt
parameter can be used as a way to check for existing authentication, verifying that the user is still present for the current session.
The authorization request returns a URL to initiate login flow. This authentication flow presents appropriate login forms to an end user and submits data provided by the user for all required sign-on steps. After all login actions in the flow are completed, the GET /{{envID}}/as/resume
endpoint continues processing the authorization request.
https://auth.pingone.com/{{envID}}/as/resume?flowId={{flowID}}
After restarting the authorization flow, the authorization code is submitted through a request to the POST /{{envID}}/as/token
endpoint to create the access token.
curl --request POST \
--url 'https://auth.pingone.com/{{envID}}/as/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data 'grant_type=authorization_code&code={{authCode}}&redirect_uri={{redirect_uri}}'
The grant_type
, code
, and redirect_uri
parameter values are required in the request body.