Using OAuth2 authentication with the Pega-provided Swagger UI
Authenticate with the Pega-provided Swagger UI so that you can test your Pega APIs, by creating an OAuth 2.0 client registration. Use the client ID and secret from your OAuth 2.0 client registration to define the scope of end-user access to the Swagger UI.
- In the navigation pane of Dev Studio, click Records.
- Expand the Security category and then click OAuth 2.0 Client Registration.
- Click on your client registration record to open it.
- On the Client Information tab, if you select the
Authorization code grant type in the
Supported grant types section, add the following URL to
use as a permitted redirect URI in the List of redirect
URIs section:
https://{Base_url}/prweb/PRRestService/SwaggerUIClient/v1/redirect.
Note: Replace {Base_url} with the domain of the current system that you are using. To use the Swagger UI with your client registration record on other systems, such as QA or Production, add the same redirect URI in each system. Replace {Base_url} with the domain name of each of the other systems. - On the Client Information tab, if you select the
Client credentials grant type in the
Supported grant types section, choose whether to set
the context by using an operator ID or access group.
- For client credentials with the operator scope, the client ID and secret is valid for all the applications that the user has access to.
- For client credentials with the access group scope, the client ID and secret is valid only for the selected application that is linked to the access group.
Tip: Ensure that you take note of the client ID and secret. You provide these values when you log in to the Swagger UI. - Access your API. For more information, see Viewing application-specific REST APIs.
- On the API page, in the Service package field, select V2 DX API.
- Click Authorize, and then configure the fields according
to your grant type.
Grant type Actions Authorization code - In the AUTHCODE (OAUTH2, AUTHORIZATION CODE) section, enter the client ID and client secret from your OAuth 2.0 client registration record.
- Click Authorize.
Password credentials - In the PASSWORD (OAUTH2, PASSWORD) section, enter the username, password, client ID, and client secret.
- In the Type field, select Request body.
- Click Authorize.
Client credentials - In the CLIENTCREDENTIALS (OAUTH2, CLIENTCREDENTIALS) section, enter the client ID and client secret from your OAuth 2.0 client registration record.
- Click Authorize.
Result: The system authenticates your credentials, and you can now use the Swagger UI. If the system displays an error, review the following guidelines: - Confirm that you entered the correct client ID and secret. You can regenerate the secret by clicking Regenerate client secret in the client registration record.
- Confirm that you saved your client registration record.
- Ensure that you entered a valid operator ID or access group in the client registration record. Confirm that the operator or access group exists, and ensure that they are configured correctly.
- Ensure that you entered the username and password correctly.
- For Auth Code authentication, confirm that you configured the redirect URI that you want to use to authenticate with Swagger in your client registration record.
For more information, see Creating and configuring an OAuth 2.0 client registration.
Previous topic Invoking a REST service rule Next topic Pega Open Robotics integration