Step 1: Send a PingOne authorization request
GET {{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow
This example shows the GET /{{envID}}/as/authorize operation to send an authorization request to the PingOne authorization server.
In this request:
-
{{envID}}represents your environment ID. -
response_modemust be set topi.flowto specify that this is a non-redirect flow. -
response_typehere has a value ofcode. In other cases, it can betoken,id_token, or a combination of these. -
client_idis the ID of the PingOne application. -
redirect_uriidentifies the redirect URI that you specified when you created the PingOne application. -
scopespecifies the OpenID Connect (OIDC) user claims are included in the token.
The request returns a 200 message when successful. The response body returns JSON instead of HTML.
|
To return JSON instead of HTML in the authorization response, this request includes an optional |
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https%3A%2F%2Fexample.com&scope=openid&response_mode=pi.flow' \
--header 'X-Requested-With: ping-sdk'
var options = new RestClientOptions("{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Get);
request.AddHeader("X-Requested-With", "ping-sdk");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https%3A%2F%2Fexample.com&scope=openid&response_mode=pi.flow"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("X-Requested-With", "ping-sdk")
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 /{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow HTTP/1.1
Host: {{authPath}}
X-Requested-With: ping-sdk
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow")
.method("GET", body)
.addHeader("X-Requested-With", "ping-sdk")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow",
"method": "GET",
"timeout": 0,
"headers": {
"X-Requested-With": "ping-sdk"
},
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'GET',
'url': '{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow',
'headers': {
'X-Requested-With': 'ping-sdk'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
url = "{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow"
payload = {}
headers = {
'X-Requested-With': 'ping-sdk'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'X-Requested-With' => 'ping-sdk'
));
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("{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https://example.com&scope=openid&response_mode=pi.flow")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["X-Requested-With"] = "ping-sdk"
response = http.request(request)
puts response.read_body
var request = URLRequest(url: URL(string: "{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=https%3A%2F%2Fexample.com&scope=openid&response_mode=pi.flow")!,timeoutInterval: Double.infinity)
request.addValue("ping-sdk", forHTTPHeaderField: "X-Requested-With")
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
{
"interactionId": "039ff9fc-097a-4e5b-be58-88ef03bf4d67",
"companyId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
"connectionId": "867ed4363b2bc21c860085ad2baa817d",
"connectorId": "api",
"id": "65u7m8cm28",
"capabilityName": "customHTMLTemplate",
"_links": {
"next": {
"href": "https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/davinci/connections/867ed4363b2bc21c860085ad2baa817d/capabilities/customHTMLTemplate"
},
"self": {
"href": "https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/davinci/policy/f34a5cc285f96ffd8e212a459b0d9134/start"
}
},
"eventName": "continue",
"isResponseCompatibleWithMobileAndWebSdks": true,
"flowId": "f49c54791bb78dc656d34e6ff38f6ffc",
"formData": {
"value": {
"username": "",
"password": ""
}
},
"form": {
"name": "Sign On",
"description": "Enter username and password",
"category": "CUSTOM_HTML",
"components": {
"fields": [
{
"type": "TEXT",
"key": "username",
"label": "Username"
},
{
"type": "PASSWORD",
"key": "password",
"label": "Password"
},
{
"type": "SUBMIT_BUTTON",
"label": "Sign On",
"key": "SIGNON"
},
{
"type": "FLOW_BUTTON",
"label": "No account? Register now!",
"key": "REGISTER",
"inputType": "ACTION"
},
{
"type": "FLOW_BUTTON",
"label": "Having trouble signing on?",
"key": "TROUBLE",
"inputType": "ACTION"
}
]
}
},
"interactionToken": "d6cd6559caf8e...",
"success": true,
"startUiSubFlow": true
}
Example Response
200 OK
{
"eventName": "continue",
"isResponseCompatibleWithMobileAndWebSdks": true,
"id": "65u7m8cm28",
"interactionId": "0309b9ed-32af-491c-9b82-1ef4c78952dd",
"companyId": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6",
"flowId": "6f37adaa00c6bad9d7b4ec966ea0903b",
"connectionId": "867ed4363b2bc21c860085ad2baa817d",
"capabilityName": "customHTMLTemplate",
"form": {
"name": "Sign On",
"description": "Enter username and password",
"category": "CUSTOM_HTML",
"components": {
"fields": [
{
"type": "TEXT",
"key": "username",
"label": "Username"
},
{
"type": "PASSWORD",
"key": "password",
"label": "Password"
},
{
"type": "SUBMIT_BUTTON",
"label": "Sign On",
"key": "SIGNON"
},
{
"type": "FLOW_BUTTON",
"label": "No account? Register now!",
"key": "REGISTER",
"inputType": "ACTION"
},
{
"type": "FLOW_BUTTON",
"label": "Having trouble signing on?",
"key": "TROUBLE",
"inputType": "ACTION"
}
],
"inputs": [
{
"key": "title",
"type": "string",
"value": "Sign On"
},
{
"key": "textOne",
"type": "string",
"value": "Welcome to Ping Identity"
},
{
"key": "textTwo",
"type": "string"
}
]
}
},
"_links": {
"next": {
"href": "https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/davinci/connections/867ed4363b2bc21c860085ad2baa817d/capabilities/customHTMLTemplate"
},
"self": {
"href": "https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/davinci/policy/2ff67ac887b2c85b5aabff4f03799f4b/start"
}
},
"startUiSubFlow": true,
"resetCookie": true
}