Scopes service


Scopes

Scopes define the permissions for an application or a user. The scopes associated with the actor determine the resources that the actor can access. For example, an application with an access token that includes the p1:read:env:user scope has read access to users resources. A user resource with an access token that includes the p1:read:self:user scope has read access to it own user resource data.

The following authorization request shows a client_credentials grant type, in which the p1:read:env:user scope is specified, ensuring that this permission is encoded into the returned access token:

curl -k -X POST -H "Accept: application/json" -d 'grant_type=client_credentials&scope=p1:read:env:user' -d 'client_id=my-client-id' -d 'client_secret=76c173fd-f323-2136-b4e6-9d8353d3721b' https://auth.pingone.com/as/token

You can specify more than one scope attribute in the authorization request by adding additional scope names separated by spaces.

curl -k -X POST -H "Accept: application/json" -d 'grant_type=client_credentials&scope=p1:read:env:user p1:create:env:user p1:read:env:userPasswordState' -d 'client_id=my-client-id' -d 'client_secret=76c173fd-f323-2136-b4e6-9d8353d3721b' https://auth.pingone.com/as/token

Note: PingOne platform scopes such as the p1:read:env:user scope cannot be modified or deleted. However, you can create custom scopes. When you create a custom scope, the POST /environments/{envId}/resources/{resId}/scopes request URL requires an environment ID and a resource ID to associate the new scope with a resource entity.

The examples below show common actions to find and manage scopes. You need the Client Application Developer role to perform operations on scopes resources.

Scopes API operations

The scopes service supports the following endpoint operations:

For hands-on experience with the scopes API endpoints, click the Run in Postman button below to download a Postman collection that you can import and open in your local Postman application.

Scopes data model

Property Description
createdAt The time the resource was created.
description A string that specifies the description of the scope.
environment.id A string that specifies the environment resource’s unique identifier associated with the resource.
id A string that specifies the scope resource’s unique identifier.
name A string that specifies the resource name.
resource.id A string that specifies the unique identifier of the resource entity associated with the scope.
updatedAt The time the resource was last updated.

Response codes

Code Message
200 Successful operation.
201 Successfully created.
204 Successfully removed. No content.
400 The request was invalid.
401 You weren’t authenticated to perform this operation.
404 The specified object doesn’t exist.

Endpoint examples

Get scopes

The GET /environments/{environmentId}/scopes endpoint returns a list of all PingOne platform scopes associated with the specified environment resource.

curl -X "GET" "https://api.pingone.com/v1/environments/0271641f-2d74-4bb0-b416-4a39b8714261/scopes" \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer jwtToken'

The response data looks like this:

{
    "_links": {
        "self": {
            "href": "https://api.pingone.com/v1/environments/0271641f-2d74-4bb0-b416-4a39b8714261/scopes"
        },
        "environment": {
            "href": "https://api.pingone.com/v1/environments/0271641f-2d74-4bb0-b416-4a39b8714261"
        }
    },
    "_embedded": {
        "scopes": [
            {
                "id": "2f465a3a-331e-44db-8c34-f9b3909bb388",
                "resource": {
                    "id": "79d29353-1508-4276-b0fa-2bffd5566aed"
                },
                "name": "phone",
                "description": "",
                "platform": true
            },
            {
                "id": "5cceac35-9df1-47e3-b858-b6547c42c2b2",
                "resource": {
                    "id": "79d29353-1508-4276-b0fa-2bffd5566aed"
                },
                "name": "email",
                "description": "",
                "platform": true
            },
            {
                "id": "afb8948c-849c-481c-8078-903084729ae4",
                "resource": {
                    "id": "79d29353-1508-4276-b0fa-2bffd5566aed"
                },
                "name": "profile",
                "description": "",
                "platform": true
            },
            {
                "id": "1a15cff1-5c6f-461e-a61f-c890dab58708",
                "resource": {
                    "id": "607d2326-5d08-475d-aab3-8e8df5237c18"
                },
                "name": "p1:update:env:userPassword",
                "description": "",
                "platform": true
            },
            {
                "id": "24d37aff-8b68-4f8c-83d3-415a1f9553c5",
                "resource": {
                    "id": "607d2326-5d08-475d-aab3-8e8df5237c18"
                },
                "name": "p1:read:env:userPasswordState",
                "description": "",
                "platform": true
            },

            ...
        ]
    },
    "size": 22
}

Get one scope

To get the list of scopes associated with a specified resource, the GET /environments/{environmentId}/resources/{resourceId}/scopes operation returns data for the scopes associated with the resource entity ID specified in the request URL.

curl -X GET "https://api.pingone.com/v1/environments/{environmentId}/resources/{resourceId}/scopes" \
-H "Content-type: application/json" \
-H "Authorization: Bearer jwtToken"

Get one scope

To get data for a single scope resource, the GET /environments/{environmentId}/resources/{resourceId}/scopes{scopeId} operation returns data for the scope resource identified by its ID in the request URL.

curl -X GET "https://api.pingone.com/v1/environments/{environmentId}/resources/{resourceId}/scopes{scopeId}" \
-H "Content-type: application/json" \
-H "Authorization: Bearer jwtToken"

Create scopes

The POST /environments/{envId}/resources/{resId}/scopes operation adds a new scope. The request URL specifies the new scope’s associated environment ID and resource ID.

curl -X "POST" "https://api.pingone.com/v1//environments/{environmentId}/resources/{resourceId}/scopes" \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer jwtToken' \
-d $'{
  "name": "photoapp:MyNewScope"
}'

The request body must specify a value for the scope name property, and the name value must be unique within the specified environment resource.

Update scopes

The PUT /environments/{environmentId}/resources/{resourceId}/scopes{scopeId} operation updates the property values of the identified scope.

curl -X "PUT" "https://api.pingone.com/v1/environments/{environmentId}/resources/{resourceId}/scopes{scopeId}/" \
-H 'Content-type: application/json' \
-H 'Authorization: Bearer jwtToken' \
-d $'{
  "name": "photoapp:edit:photos",
  "description": "Allows users to edit their photo files."
}'

The request body specifies updated values for the scope name and description properties. Any property values not specified in the request body are cleared. The response returns a 200 OK message, and it shows the updated property data for the modified scope resource.

Delete scopes

The following sample shows the DELETE /environments/{environmentId}/resources/{resourceId}/scopes{scopeId} operation to delete the scope.

curl -X DELETE "https://api.pingone.com/v1/environments/{environmentId}/resources/{resourceId}/scopes{scopeId}" \
-H "Content-type: application/json" \
-H "Authorization: Bearer jwtToken" \

When successful, the DELETE request returns a code 204 No Content message.