PingOne Platform APIs

Get Key Rotation Policies

     

GET {{apiPath}}/environments/{{envID}}/keyRotationPolicies

The GET {{apiPath}}/environments/{{envID}}/keyRotationPolicies endpoint returns all KRPs for the specified environment. This endpoint supports the filter pagination query parameter.

Headers

Authorization      Bearer {{accessToken}}

Example Request

  • cURL

  • C#

  • Go

  • HTTP

  • Java

  • jQuery

  • NodeJS

  • Python

  • PHP

  • Ruby

  • Swift

curl --location --globoff '{{apiPath}}/environments/{{envID}}/keyRotationPolicies' \
--header 'Authorization: Bearer {{accessToken}}'
var options = new RestClientOptions("{{apiPath}}/environments/{{envID}}/keyRotationPolicies")
{
  MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Get);
request.AddHeader("Authorization", "Bearer {{accessToken}}");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {

  url := "{{apiPath}}/environments/{{envID}}/keyRotationPolicies"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "Bearer {{accessToken}}")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
GET /environments/{{envID}}/keyRotationPolicies HTTP/1.1
Host: {{apiPath}}
Authorization: Bearer {{accessToken}}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
  .url("{{apiPath}}/environments/{{envID}}/keyRotationPolicies")
  .method("GET", body)
  .addHeader("Authorization", "Bearer {{accessToken}}")
  .build();
Response response = client.newCall(request).execute();
var settings = {
  "url": "{{apiPath}}/environments/{{envID}}/keyRotationPolicies",
  "method": "GET",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer {{accessToken}}"
  },
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require('request');
var options = {
  'method': 'GET',
  'url': '{{apiPath}}/environments/{{envID}}/keyRotationPolicies',
  'headers': {
    'Authorization': 'Bearer {{accessToken}}'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "{{apiPath}}/environments/{{envID}}/keyRotationPolicies"

payload = {}
headers = {
  'Authorization': 'Bearer {{accessToken}}'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{apiPath}}/environments/{{envID}}/keyRotationPolicies');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer {{accessToken}}'
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
require "uri"
require "net/http"

url = URI("{{apiPath}}/environments/{{envID}}/keyRotationPolicies")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer {{accessToken}}"

response = http.request(request)
puts response.read_body
var request = URLRequest(url: URL(string: "{{apiPath}}/environments/{{envID}}/keyRotationPolicies")!,timeoutInterval: Double.infinity)
request.addValue("Bearer {{accessToken}}", forHTTPHeaderField: "Authorization")

request.httpMethod = "GET"

let task = URLSession.shared.dataTask(with: request) { data, response, error in
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
}

task.resume()

Example Response

200 OK

{
    "_links": {
        "self": {
            "href": "https://api.pingone.com/v1/environments/1p64ab27-ac87-4171-84m1-9b4690b6e420/keyRotationPolicies"
        },
        "environment": {
            "href": "https://api.pingone.com/v1/environments/1p64ab27-ac87-4171-84m1-9b4690b6e420"
        }
    },
    "_embedded": {
        "keyRotationPolicies": [
            {
                "id": "13a03c5f-825d-47f3-95e8-20ac19f51251",
                "environment": {
                    "id": "1p64ab27-ac87-4171-84m1-9b4690b6e420"
                },
                "name": "PingOne Key Rotation Policy for My Environment environment",
                "usageType": "SIGNING",
                "default": true,
                "dn": "C=US,O=Ping Identity,OU=Ping Identity,CN=PingOne Key Rotation Policy for My Environment environment",
                "algorithm": "RSA",
                "keyLength": 2048,
                "validityPeriod": 365,
                "signatureAlgorithm": "SHA256withRSA",
                "rotationPeriod": 90,
                "currentKeyId": "47c36180-71cb-11ed-8dcd-9da5faeb9995",
                "nextKeyId": "47d53bd0-71cb-11ed-8dcd-9da5faeb9995",
                "rotatedAt": "2022-12-01T22:55:41.356Z"
            },
            {
                "id": "1bd9c76c-6103-4c4c-a4ec-af66c0504ff7",
                "environment": {
                    "id": "1p64ab27-ac87-4171-84m1-9b4690b6e420"
                },
                "name": "Test Key Rotation Policy",
                "usageType": "SIGNING",
                "default": false,
                "dn": "CN=Test Key Rotation Policy, OU=Ping Identity, O=Ping Identity, C=US",
                "algorithm": "RSA",
                "keyLength": 2048,
                "validityPeriod": 365,
                "signatureAlgorithm": "SHA256withRSA",
                "rotationPeriod": 120,
                "currentKeyId": "4dc219c0-7679-11ed-bb86-f73f994c34e2",
                "nextKeyId": "4de02910-7679-11ed-bb86-f73f994c34e2",
                "rotatedAt": "2022-12-07T21:51:28.501Z"
            }
        ]
    },
    "size": 2
}