Cancel Device Authentication
POST {{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}
This example shows how to cancel an authentication process that has begun. You can use this in situations where the user wants to authenticate from a different device. Note that this feature requires version 2.0 or higher of the PingOne MFA SDK.
The ID of the device authentication attempt is included in the URL: {{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}
The value of the Content-Type header must be set to: application/vnd.pingidentity.cancel.push.authentication+json
The body consists of a single field, reason, which is set to CHANGE_DEVICE.
Request Model
| Property | Type | Required? |
|---|---|---|
|
String |
Required |
Refer to the Device authentications data model for full property descriptions.
Example Request
-
cURL
-
C#
-
Go
-
HTTP
-
Java
-
jQuery
-
NodeJS
-
Python
-
PHP
-
Ruby
-
Swift
curl --location --globoff '{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}' \
--header 'Content-Type: application/vnd.pingidentity.cancel.push.authentication+json' \
--header 'Authorization: Bearer {{accessToken}}' \
--data '{
"reason": "CHANGE_DEVICE"
}'
var options = new RestClientOptions("{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("", Method.Post);
request.AddHeader("Content-Type", "application/vnd.pingidentity.cancel.push.authentication+json");
request.AddHeader("Authorization", "Bearer {{accessToken}}");
var body = @"{" + "\n" +
@" ""reason"": ""CHANGE_DEVICE""" + "\n" +
@"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}"
method := "POST"
payload := strings.NewReader(`{
"reason": "CHANGE_DEVICE"
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/vnd.pingidentity.cancel.push.authentication+json")
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))
}
POST /{{envID}}/deviceAuthentications/{{deviceAuthID}} HTTP/1.1
Host: {{authPath}}
Content-Type: application/vnd.pingidentity.cancel.push.authentication+json
Authorization: Bearer {{accessToken}}
{
"reason": "CHANGE_DEVICE"
}
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/vnd.pingidentity.cancel.push.authentication+json");
RequestBody body = RequestBody.create(mediaType, "{\n \"reason\": \"CHANGE_DEVICE\"\n}");
Request request = new Request.Builder()
.url("{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}")
.method("POST", body)
.addHeader("Content-Type", "application/vnd.pingidentity.cancel.push.authentication+json")
.addHeader("Authorization", "Bearer {{accessToken}}")
.build();
Response response = client.newCall(request).execute();
var settings = {
"url": "{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/vnd.pingidentity.cancel.push.authentication+json",
"Authorization": "Bearer {{accessToken}}"
},
"data": JSON.stringify({
"reason": "CHANGE_DEVICE"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
var request = require('request');
var options = {
'method': 'POST',
'url': '{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}',
'headers': {
'Content-Type': 'application/vnd.pingidentity.cancel.push.authentication+json',
'Authorization': 'Bearer {{accessToken}}'
},
body: JSON.stringify({
"reason": "CHANGE_DEVICE"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}"
payload = json.dumps({
"reason": "CHANGE_DEVICE"
})
headers = {
'Content-Type': 'application/vnd.pingidentity.cancel.push.authentication+json',
'Authorization': 'Bearer {{accessToken}}'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Content-Type' => 'application/vnd.pingidentity.cancel.push.authentication+json',
'Authorization' => 'Bearer {{accessToken}}'
));
$request->setBody('{\n "reason": "CHANGE_DEVICE"\n}');
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 "json"
require "net/http"
url = URI("{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/vnd.pingidentity.cancel.push.authentication+json"
request["Authorization"] = "Bearer {{accessToken}}"
request.body = JSON.dump({
"reason": "CHANGE_DEVICE"
})
response = http.request(request)
puts response.read_body
let parameters = "{\n \"reason\": \"CHANGE_DEVICE\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "{{authPath}}/{{envID}}/deviceAuthentications/{{deviceAuthID}}")!,timeoutInterval: Double.infinity)
request.addValue("application/vnd.pingidentity.cancel.push.authentication+json", forHTTPHeaderField: "Content-Type")
request.addValue("Bearer {{accessToken}}", forHTTPHeaderField: "Authorization")
request.httpMethod = "POST"
request.httpBody = postData
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://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/deviceAuthentications/004fd27a-c7e7-4e63-8644-0563e43dcd02"
},
"device.select": {
"href": "https://auth.pingone.com/abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6/deviceAuthentications/004fd27a-c7e7-4e63-8644-0563e43dcd02"
}
},
"_embedded": {
"devices": [
{
"id": "3c325a86-283d-4fdf-bfda-239900d1ce8d",
"type": "MOBILE",
"status": "ACTIVE",
"usableStatus": {
"status": "ENABLED"
},
"nickname": "AsafAuth1",
"os": {
"version": "11",
"type": "ANDROID"
},
"apiVersion": "1.0",
"locale": "en-IL",
"model": {
"name": "IN2023",
"marketingName": "IN2023"
},
"application": {
"id": "edb09bb3-fc85-438b-a025-25a444e276e6",
"nativeName": "AsafAuth",
"version": "1.0.0",
"name": "AsafAuth",
"pushSandbox": false,
"passcodeRefreshDuration": {
"duration": 30,
"timeUnit": "SECONDS"
}
},
"pushEnabled": true,
"manufacturer": "OnePlus",
"sdkVersion": "1.2.0(5509)",
"rooted": false,
"lockEnabled": true,
"notification": "enabled",
"background": "unknown",
"pushStatus": {
"status": "ENABLED"
},
"otpEnabled": false,
"otpStatus": {
"status": "DISABLED",
"reason": "OTP_NOT_SUPPORTED_BY_SDK_VERSION"
},
"pushFails": [
1730814224932
]
},
{
"id": "a8ccb1b3-0809-43c2-881b-f624a417e8aa",
"type": "FIDO2",
"status": "ACTIVE",
"usableStatus": {
"status": "ENABLED"
},
"attributes": {
"previousDeviceType": "PLATFORM",
"isCrossPlatform": false
},
"rp": {
"id": "pingone.com",
"name": "PingOne"
},
"credentialId": "AejegVUIW1cbhyL0zIBsD44lZsb--PkKwK9ydrDMcL-rHx3_u9jGLyMSuMn7DAgDlB5pl1TSkmTSziTh8bpbgzo",
"displayName": "fidoPolicy.deviceDisplayName01"
},
{
"id": "259e5a50-46bb-4696-883b-ea14bb36bdf9",
"type": "MOBILE",
"status": "ACTIVE",
"usableStatus": {
"status": "ENABLED"
},
"deviceIntegrityState": {
"compromised": "UNKNOWN",
"reason": "PLAY_MISSING_CONFIGURATION",
"timestamp": 1686050056879
},
"os": {
"version": "13",
"type": "ANDROID"
},
"apiVersion": "2.0",
"locale": "en-IL",
"model": {
"name": "IN2023",
"marketingName": "IN2023"
},
"application": {
"id": "15810c80-21a0-4e0e-9fc4-d95e951147c1",
"nativeName": "PingOneInternal",
"version": "1.10.0",
"name": "NativeAppForInternalApp",
"pushSandbox": false,
"passcodeRefreshDuration": {
"duration": 30,
"timeUnit": "SECONDS"
}
},
"pushEnabled": true,
"manufacturer": "OnePlus",
"sdkVersion": "1.10.0(9224)",
"rooted": false,
"lockEnabled": true,
"notificationProvider": "FCM",
"notification": "enabled",
"background": "available",
"allowPushNotification": true,
"pushStatus": {
"status": "ENABLED"
},
"otpEnabled": false,
"otpStatus": {
"status": "DISABLED",
"reason": "OTP_NOT_SUPPORTED"
},
"pushFails": []
},
{
"id": "39edc3b1-8d69-4788-acbb-3cf2fe1c9897",
"type": "FIDO2",
"status": "ACTIVE",
"usableStatus": {
"status": "ENABLED"
},
"attributes": {
"isCrossPlatform": false
},
"rp": {
"id": "pingone.com",
"name": "PingOne"
},
"credentialId": "tPb8yfpRxX7cbW3gEVzRKSRwKxXCq5tl0dOByCvbviY",
"fidoRegistrationArtifacts": {
"attestationType": "NONE"
},
"backup": {
"backupEligibility": false,
"backupState": false
},
"displayName": "fidoPolicy.deviceDisplayName01"
},
{
"id": "daba8c2b-5f01-42fa-91a5-ee91e58b0b26",
"type": "EMAIL",
"status": "ACTIVE",
"usableStatus": {
"status": "ENABLED"
},
"email": "ad****@pingidentity.com"
}
],
"blockedDevices": []
},
"id": "004fd27a-c7e7-4e63-8644-0563e43dcd02",
"environment": {
"id": "abfba8f6-49eb-49f5-a5d9-80ad5c98f9f6"
},
"status": "DEVICE_SELECTION_REQUIRED",
"policy": {
"id": "6ad97c12-cfa6-0f90-1332-0274be07e414"
},
"selectedDevice": {
"id": "3c325a86-283d-4fdf-bfda-239900d1ce8d"
},
"user": {
"id": "8f8a6354-6153-4430-964e-e10d4e5deed3"
},
"bypassAllowed": false,
"createdAt": "2024-11-05T13:43:27.272Z",
"updatedAt": "2024-11-05T13:43:44.939Z",
"aggregateFido2Devices": false,
"userBypassEnabled": false
}