Step 4: Send an authorization request
GET {{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid
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_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={{dvFlowAppID}}&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Flogin%2Fcallback&scope=openid'
var options = new RestClientOptions("{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid")
{
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={{dvFlowAppID}}&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Flogin%2Fcallback&scope=openid"
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={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid 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={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid")
.method("GET", body)
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{authPath}}/{{envID}}/as/authorize?response_type=code&client_id={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid",
"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={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid',
'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={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid"
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={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid');
$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={{dvFlowAppID}}&redirect_uri=http://localhost:3000/login/callback&scope=openid")
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={{dvFlowAppID}}&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Flogin%2Fcallback&scope=openid")!,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
<!DOCTYPE html>
<html>
<head>
<!-- Flow loading props-->
<!-- singularkey-styles-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/davinci/flows/56cb8816d1a789c6bcc71b7b5f2298a5/css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="https://assets.singularkey.com/assets/favicon-davinci.png">
<!-- Load custom css files from flow settings-->
<link href="https://assets.pingone.com/ux/end-user/1.7.0/end-user.css" rel="stylesheet" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous"></script>
</head>
<body>
<!-- Flow loading props-->
<div>
<div id="widgetContainer"></div>
</div>
<form id="pingOneDaVinciResponseForm" name="pingOneDaVinciResponseForm" method="POST" action="https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/as/resume" autocomplete="off">
<input type="hidden" id="dvResponse" name="dvResponse" value="">
<input type="hidden" id="state" name="state" value="03c1756e-4115-4b50-81b7-9557886160eb">
</form>
<!-- Load react-sk widget-->
<script src="https://assets.pingone.com/davinci/latest/davinci.js"></script>
<script type="text/javascript">var skProps = {"method":"runFlow","apiRoot":"https://auth.pingone.com","accessToken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IkpoRkpRdVo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uuZqScrchtlvAgxb6IXO238OCBHp7Xu6TXcdYRsCMD9rO6H8SWK9vsu1DEfdeadesBLfyiN-HenOMyM","companyId":"abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6","policyId":"ff5d4b1a72b98a00598df1a7124409ef","originCookies":[]}
var skLoadingProps = {"intermediateLoadingScreenHTML":null,"intermediateLoadingScreenCSS":null,"customTitle":null,"customFaviconLink":null}
function submit() {
// Prevent unused inputs from being submitted
const dvResponseForm = document.forms.pingOneDaVinciResponseForm;
const inputs = dvResponseForm.getElementsByTagName('input');
for (let i = 0; i < inputs.length; i++) {
const input = inputs[i];
if (!(input.name === 'dvResponse' || input.name === 'state')) {
input.removeAttribute('name');
}
}
dvResponseForm.submit();
}
function successCallback(response) {
if (response?.dvResponse) {
document.forms.pingOneDaVinciResponseForm.dvResponse.value = response.dvResponse;
submit();
} }
function errorCallback(error) {
if (error?.dvResponse) {
document.forms.pingOneDaVinciResponseForm.dvResponse.value = error.dvResponse;
submit();
} }
function loadIt(){
var param = {config: skProps, skLoadingProps, successCallback, errorCallback}
davinci.renderScreen($('#widgetContainer').get(0), param)
}
loadIt()
</script>
<!-- Load custom javascript files from flow settings-->
</body>
</html>