Step 4: Send an authorization request
GET {{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&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.
|
For authorization and flow requests, the PingOne endpoint domain is |
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 that you created in a prior step. -
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
200message when successful. The response body contains HTML that creates the sign-on form.
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=http%3A%2F%2Flocalhost%3A3000%2Flogin%2Fcallback&scope=openid&response_mode=pi.flow'
var options = new RestClientOptions("{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Get);
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=http%3A%2F%2Flocalhost%3A3000%2Flogin%2Fcallback&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
}
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=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow HTTP/1.1
Host: {{authPath}}
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=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow")
.method("GET", body)
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvPiFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow",
"method": "GET",
"timeout": 0,
};
$.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=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow',
'headers': {
}
};
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=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow"
payload = {}
headers = {}
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=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
'follow_redirects' => TRUE
));
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=http://localhost:3000/login/callback&scope=openid&response_mode=pi.flow")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
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=http%3A%2F%2Flocalhost%3A3000%2Flogin%2Fcallback&scope=openid&response_mode=pi.flow")!,timeoutInterval: Double.infinity)
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
{
"id": "howu8n9hsc",
"companyId": "082dba86-...",
"flowId": "56cb8816d1...",
"connectionId": "867ed4363b2...",
"capabilityName": "customHTMLTemplate",
"screen": {
"name": "HTTP",
"properties": {
"sktemplate": {
"type": "string",
"displayName": "Template",
"createdDate": 1694542156374,
"customerId": "ecb9bf8a...",
"companyId": "singularkey"
},
"customHTML": {
"type": "string",
"displayName": "HTML Template",
"createdDate": 1694542156417,
"customerId": "ecb9bf8a2fa...",
"companyId": "singularkey",
"preferredControlType": "textArea",
"enableParameters": true,
"maximizeToggle": true,
"viewToggle": true,
"largePayload": true,
"value": "<div class=\"app-container\" style=\"display: block;\">\n\t<div class=\"page__content\" style=\"height: 100%;\">\n\t\t<div class=\"card card--no-padding\">\n\t\t\t<div class=\"card__content\">\n\t\t\t\t</div>\n\t\t\t\t<div data-skcomponent=\"skerror\" class=\"feedback feedback--error sk-alert sk-alert-danger has-text-danger has-background-danger-light\" data-id=\"feedback\" data-skvisibility=\"\"></div>\n\t\t\t\t<form class=\"form\" id='usernamePasswordForm' data-id=\"usernamePasswordForm\">\n\t\t\t\t\t<div class=\"field float-label\">\n\t\t\t\t\t\t<input class=\"text-input float-label__input\" data-id=\"username-input\" id=\"username\" name=\"username\" type=\"text\" autocomplete=\"on\" value=\"\" />\n\t\t\t\t\t\t<label class=\"float-label__label\" for=\"username\">Username</label>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"field float-label\">\n\t\t\t\t\t\t<input class=\"text-input text-input--pasword float-label__input\" data-id=\"password-input\" id=\"password\" name=\"password\" type=\"password\" autocomplete=\"on\" value=\"\" />\n\t\t\t\t\t\t<label class=\"float-label__label\" for=\"password\">Password</label>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"control\">\n\t\t\t\t\t\t<button class=\"field is-primary mt-2 button file-input--button button--primary brand-primary-bg\" data-id=\"button\" type=\"submit\" data-skcomponent=\"skbutton\" data-skbuttontype=\"form-submit\" data-skform=\"usernamePasswordForm\" data-skbuttonvalue=\"submit\">\n Sign On\n\t\t\t\t\t\t\t<i class=\"fas fa-forward ml-2\"></i>\n\t\t\t\t\t\t</button>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"control\">\n <div style=\"width: 90%; text-align: center;\">\n <button type=\"submit\" class=\"buttonLink is-primary is-inverted mt-2\" data-skcomponent=\"skbutton\" data-skbuttontype=\"form-submit\" data-skform=\"usernamePasswordForm\" data-skbuttonvalue=\"forgotPassword\">\n Forgot Password\n <i class=\"fas fa-forward ml-2\"></i>\n </button>\n </div>\n\t\t\t\t\t</div>\n\t\t\t\t</form>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n</div>\n"
},
"validationRules": {
"type": "object",
"displayName": "Form validation rules",
"info": "Rules to check to validate form inputs",
"createdDate": 1694542156291,
"customerId": "ecb9bf8a...",
"companyId": "singularkey",
"preferredControlType": "validationRules"
},
"customCSS": {
"type": "string",
"displayName": "CSS",
"createdDate": 1694542156320,
"customerId": "ecb9bf8a...",
"companyId": "singularkey",
"preferredControlType": "codeEditor",
"language": "css",
"maximizeToggle": true,
"largePayload": true
},
"customScript": {
"type": "string",
"displayName": "Script",
"createdDate": 1694542156320,
"customerId": "ecb9bf8a2fa...",
"companyId": "singularkey",
"preferredControlType": "codeEditor",
"value": "",
"language": "javascript",
"maximizeToggle": true,
"info": "Write custom JavaScript. Caution: Custom code is for advanced users only. Before using custom code, review the security risks in the DaVinci documentation by searching for \"Using custom code safely\"."
},
"inputSchema": {
"type": "string",
"displayName": "Input Schema",
"createdDate": 1694542156288,
"customerId": "ecb9bf8a2...",
"companyId": "singularkey",
"preferredControlType": "codeEditor",
"language": "json",
"info": "Follow example for JSON schema.",
"maximizeToggle": true
},
"outputSchema": {
"type": "string",
"displayName": "Output Schema",
"createdDate": 1694542156271,
"customerId": "ecb9bf8a...",
"companyId": "singularkey",
"preferredControlType": "codeEditor",
"language": "json",
"info": "Follow example for JSON schema.",
"maximizeToggle": true
},
"formFieldsList": {
"type": "array",
"constructType": "formFieldsList",
"displayName": "Output Fields List",
"createdDate": 1694542156244,
"customerId": "ecb9bf8a...",
"companyId": "singularkey",
"preferredControlType": "formFieldsList",
"hideLabel": false,
"value": [
{
"preferredControlType": "textField",
"preferredDataType": "string",
"propertyName": "username",
"displayName": "Username",
"hashedVisibility": false
},
{
"preferredControlType": "textField",
"preferredDataType": "string",
"propertyName": "password",
"displayName": "Password",
"hashedVisibility": true
},
{
"preferredControlType": "textField",
"preferredDataType": "string",
"propertyName": "buttonValue"
}
]
},
"challenge": {
"type": "string",
"displayName": "Challenge",
"createdDate": 1694542156314,
"customerId": "ecb9bf8a...",
"companyId": "singularkey",
"preferredControlType": "textField",
"enableParameters": true
},
"button": {
"constructType": "button",
"displayName": "Submit",
"createdDate": 1694542156280,
"customerId": "ecb9bf8a2fa...",
"companyId": "singularkey",
"logo": "",
"showLogo": true,
"preferredControlType": "button",
"css": {
"backgroundColor": "#1CAB42",
"color": "#ffffff"
},
"onClick": {
"constructType": "skEvent",
"eventName": "continue",
"eventType": "post",
"postProcess": {}
}
},
"showFooter": {
"value": true
},
"returnRequestParameters": {
"value": true
},
"messageTitle": {
"value": "Information"
},
"message": {
"value": ""
},
"showPoweredBy": {
"value": false
},
"showContinueButton": {
"value": false
},
"enablePolling": {
"value": false
},
"pollInterval": {
"value": 2000
},
"pollRetries": {
"value": 60
},
"pollChallengeStatus": {
"value": true
},
"httpMethod": {
"value": "GET"
},
"httpBody": {
"value": "none"
},
"raw": {
"value": ""
},
"signResponse": {
"value": false
},
"additionalFieldsName": {
"value": "additionalProperties"
},
"unsafeIgnoreTLSErrors": {
"value": false
},
"delayTime": {
"value": 50
},
"returnSuccess": {
"value": true
},
"keepOutputIfNotValid": {
"value": false
},
"fieldValidation": {
"value": false
},
"outboundMtlsKey": {
"value": "none"
},
"nodeTitle": {
"value": "Username/Password Form"
},
"isLinkStyleSheetSupportEnabled": {
"value": false
}
},
"userViews": [
{
"screenTemplateName": "CustomHTMLTemplate",
"items": [
{
"propertyName": "sktemplate"
},
{
"propertyName": "customHTML"
},
{
"propertyName": "validationRules"
},
{
"propertyName": "customCSS"
},
{
"propertyName": "customScript"
},
{
"propertyName": "inputSchema"
},
{
"propertyName": "outputSchema"
},
{
"propertyName": "formFieldsList"
},
{
"propertyName": "challenge"
},
{
"propertyName": "button"
}
]
}
],
"metadata": {
"colors": {
"canvas": "#AFD5FF",
"canvasText": "#253746",
"dark": "#2E5EA6"
},
"logos": {
"canvas": {
"imageFileName": "http.svg"
}
},
"type": "core",
"vendor": ""
}
},
"interactionId": "03758786...",
"interactionToken": "b710eaf68bbe...",
"skProxyApiEnvironmentId": "us-west-2",
"_links": {
"self": {
"href": "https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/davinci/policy/ff5d4b1a72b98a00598df1a7124409ef/start"
}
}
}