Create authorization for a user
With this endpoint you can create an authorization code for a user. Note: the bearer token needs special privilege to perform this task, please contact your contact person at Findity if you need this access.
To address a user you need to provide the id or externalSourceId from the person object.
curl --request POST \
--url https://stage-api.findity.com/api/oauth/authorization-grant \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data user_id=8ab28c3e6f8023c3016f8046be110002 \
--data external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541import requests
url = "https://stage-api.findity.com/api/oauth/authorization-grant"
payload = {
"user_id": "8ab28c3e6f8023c3016f8046be110002",
"external_user_id": "ca2c4726-b376-11ed-8a5b-ebc76439f541"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
user_id: '8ab28c3e6f8023c3016f8046be110002',
external_user_id: 'ca2c4726-b376-11ed-8a5b-ebc76439f541'
})
};
fetch('https://stage-api.findity.com/api/oauth/authorization-grant', 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://stage-api.findity.com/api/oauth/authorization-grant",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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://stage-api.findity.com/api/oauth/authorization-grant"
payload := strings.NewReader("user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://stage-api.findity.com/api/oauth/authorization-grant")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541")
.asString();require 'uri'
require 'net/http'
url = URI("https://stage-api.findity.com/api/oauth/authorization-grant")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541"
response = http.request(request)
puts response.read_body{
"code": "713ebf7ef91559f99c5ef9edfcab345c"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Internal user id (personId). Any user can use this endpoint with their own user_id, other use cases requires special permissions.
External user id (externalSourceId for person).
Optional. Id of the client application the authorization code is for. When omitted, the user's own client application is used, falling back to the caller's. The X-Findity-ClientApplicationId header is used as a last fallback. An unknown id fails with 400 invalid_request "invalid applicationId", and an application the user may not use fails with 400 invalid_request "not authorized for this applicationId".
Response
OK
Authorization code that can be used in a request to /oauth/token
curl --request POST \
--url https://stage-api.findity.com/api/oauth/authorization-grant \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data user_id=8ab28c3e6f8023c3016f8046be110002 \
--data external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541import requests
url = "https://stage-api.findity.com/api/oauth/authorization-grant"
payload = {
"user_id": "8ab28c3e6f8023c3016f8046be110002",
"external_user_id": "ca2c4726-b376-11ed-8a5b-ebc76439f541"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/x-www-form-urlencoded"
}
response = requests.post(url, data=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
Authorization: 'Bearer <token>',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams({
user_id: '8ab28c3e6f8023c3016f8046be110002',
external_user_id: 'ca2c4726-b376-11ed-8a5b-ebc76439f541'
})
};
fetch('https://stage-api.findity.com/api/oauth/authorization-grant', 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://stage-api.findity.com/api/oauth/authorization-grant",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/x-www-form-urlencoded"
],
]);
$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://stage-api.findity.com/api/oauth/authorization-grant"
payload := strings.NewReader("user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://stage-api.findity.com/api/oauth/authorization-grant")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/x-www-form-urlencoded")
.body("user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541")
.asString();require 'uri'
require 'net/http'
url = URI("https://stage-api.findity.com/api/oauth/authorization-grant")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-www-form-urlencoded'
request.body = "user_id=8ab28c3e6f8023c3016f8046be110002&external_user_id=ca2c4726-b376-11ed-8a5b-ebc76439f541"
response = http.request(request)
puts response.read_body{
"code": "713ebf7ef91559f99c5ef9edfcab345c"
}
