Create Auth Token to Initialise the SDK
curl --request POST \
--url https://sandbox.cashfree.com/verification/oauth/token \
--header 'Content-Type: application/json' \
--header 'x-client-id: <api-key>' \
--header 'x-client-secret: <api-key>' \
--data '
{
"app_id": "<string>",
"product": "VKYC",
"metadata": {
"vkyc_request_id": 249749
},
"authenticated_user": {
"identifier_type": "mobile",
"identifier_value": 9909490494
}
}
'import requests
url = "https://sandbox.cashfree.com/verification/oauth/token"
payload = {
"app_id": "<string>",
"product": "VKYC",
"metadata": { "vkyc_request_id": 249749 },
"authenticated_user": {
"identifier_type": "mobile",
"identifier_value": 9909490494
}
}
headers = {
"x-client-id": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-id': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
app_id: '<string>',
product: 'VKYC',
metadata: {vkyc_request_id: 249749},
authenticated_user: {identifier_type: 'mobile', identifier_value: 9909490494}
})
};
fetch('https://sandbox.cashfree.com/verification/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/verification/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'app_id' => '<string>',
'product' => 'VKYC',
'metadata' => [
'vkyc_request_id' => 249749
],
'authenticated_user' => [
'identifier_type' => 'mobile',
'identifier_value' => 9909490494
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-client-id: <api-key>",
"x-client-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.cashfree.com/verification/oauth/token"
payload := strings.NewReader("{\n \"app_id\": \"<string>\",\n \"product\": \"VKYC\",\n \"metadata\": {\n \"vkyc_request_id\": 249749\n },\n \"authenticated_user\": {\n \"identifier_type\": \"mobile\",\n \"identifier_value\": 9909490494\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<api-key>")
req.Header.Add("x-client-secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/verification/oauth/token")
.header("x-client-id", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"app_id\": \"<string>\",\n \"product\": \"VKYC\",\n \"metadata\": {\n \"vkyc_request_id\": 249749\n },\n \"authenticated_user\": {\n \"identifier_type\": \"mobile\",\n \"identifier_value\": 9909490494\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/verification/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-client-id"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"app_id\": \"<string>\",\n \"product\": \"VKYC\",\n \"metadata\": {\n \"vkyc_request_id\": 249749\n },\n \"authenticated_user\": {\n \"identifier_type\": \"mobile\",\n \"identifier_value\": 9909490494\n }\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires_at": "2024-02-02 17:30:00 IST"
}Create Auth Token to Initialise the SDK
Use this API to generate an authentication token required to initialize the Cashfree SDK. Provide your app_id, and product name (such as Video KYC) in the request body. The API returns an access_token and its expiry details.
POST
/
oauth
/
token
Create Auth Token to Initialise the SDK
curl --request POST \
--url https://sandbox.cashfree.com/verification/oauth/token \
--header 'Content-Type: application/json' \
--header 'x-client-id: <api-key>' \
--header 'x-client-secret: <api-key>' \
--data '
{
"app_id": "<string>",
"product": "VKYC",
"metadata": {
"vkyc_request_id": 249749
},
"authenticated_user": {
"identifier_type": "mobile",
"identifier_value": 9909490494
}
}
'import requests
url = "https://sandbox.cashfree.com/verification/oauth/token"
payload = {
"app_id": "<string>",
"product": "VKYC",
"metadata": { "vkyc_request_id": 249749 },
"authenticated_user": {
"identifier_type": "mobile",
"identifier_value": 9909490494
}
}
headers = {
"x-client-id": "<api-key>",
"x-client-secret": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-client-id': '<api-key>',
'x-client-secret': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
app_id: '<string>',
product: 'VKYC',
metadata: {vkyc_request_id: 249749},
authenticated_user: {identifier_type: 'mobile', identifier_value: 9909490494}
})
};
fetch('https://sandbox.cashfree.com/verification/oauth/token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/verification/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'app_id' => '<string>',
'product' => 'VKYC',
'metadata' => [
'vkyc_request_id' => 249749
],
'authenticated_user' => [
'identifier_type' => 'mobile',
'identifier_value' => 9909490494
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-client-id: <api-key>",
"x-client-secret: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.cashfree.com/verification/oauth/token"
payload := strings.NewReader("{\n \"app_id\": \"<string>\",\n \"product\": \"VKYC\",\n \"metadata\": {\n \"vkyc_request_id\": 249749\n },\n \"authenticated_user\": {\n \"identifier_type\": \"mobile\",\n \"identifier_value\": 9909490494\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<api-key>")
req.Header.Add("x-client-secret", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/verification/oauth/token")
.header("x-client-id", "<api-key>")
.header("x-client-secret", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"app_id\": \"<string>\",\n \"product\": \"VKYC\",\n \"metadata\": {\n \"vkyc_request_id\": 249749\n },\n \"authenticated_user\": {\n \"identifier_type\": \"mobile\",\n \"identifier_value\": 9909490494\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/verification/oauth/token")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-client-id"] = '<api-key>'
request["x-client-secret"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"app_id\": \"<string>\",\n \"product\": \"VKYC\",\n \"metadata\": {\n \"vkyc_request_id\": 249749\n },\n \"authenticated_user\": {\n \"identifier_type\": \"mobile\",\n \"identifier_value\": 9909490494\n }\n}"
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
"expires_at": "2024-02-02 17:30:00 IST"
}Authorizations
Client ID. You can find your ID in the Merchant Dashboard.
Client secret key. You can find your secret key in the Merchant Dashboard.
Body
application/json
Request payload for create auth token to initialise the SDK.
