const payload = new Payload({
issuance_token: attributeIssuanceDetails.getToken(),
attributes: [
{
name: 'com.example.someAttribute',
value: 'some attribute value',
},
],
});
const request = new RequestBuilder()
.withBaseUrl('https://api.yoti.com/api/v1/attribute-registry')
.withEndpoint('/attributes')
.withPemString('PEM_CONTENT')
.withHeader('X-Yoti-Auth-Id', 'CLIENT_SDK_ID')
.withMethod('POST')
.withPayload(payload)
.build();
const response = await request.execute();
// Note:
// - Use RequestBuilder::withPemFilePath() to provide a file path
// (This may have performance implications)
byte[] payload = ...; // Payload is JSON converted to byte array
SignedRequest signedRequest = SignedRequestBuilderFactory.create()
.withKeyPair("PEM_CONTENT")
.withBaseUrl("https://api.yoti.com/api/v1/attribute-registry")
.withEndpoint("/attributes")
.withHttpMethod("POST")
.withHeader("X-Yoti-Auth-Id", "CLIENT_SDK_ID")
.withPayload(payload)
.build();
// 'SomeModel' is a POJO that has been defined by the user and is
// used to map JSON response as the SDK doesn't have any built in
// classes to support this
SomeModel someModel = signedRequest.execute(SomeModel.class);
/**
* SignedRequest.execute() uses built in Java HTTP connectivity.
* To use another framework if required (e.g. apache), you can get
* all of the pieces of the Yoti signed request off the SignedRequest
* object e.g.
**/
URI uri = signedRequest.getUri();
String httpMethod = signedRequest.getMethod();
byte[] payloadData = signedRequest.getData();
Map<String, String> headers = signedRequest.getHeaders();
<?php
use Yoti\Http\Payload;
use Yoti\Http\RequestBuilder;
$payload = Payload::fromJsonData((object) [
'issuance_token' => $attributeIssuanceDetails->getToken(),
'attributes' => [
(object) [
'name' => 'com.example.someAttribute',
'value' => 'some attribute value',
],
],
]);
$request = (new RequestBuilder())
->withBaseUrl('https://api.yoti.com/api/v1/attribute-registry')
->withEndpoint('/attributes')
->withPemFilePath('/path/to/key.pem')
->withHeader('X-Yoti-Auth-Id', 'CLIENT_SDK_ID')
->withMethod('POST')
->withPayload($payload)
->build();
$response = $request->execute();
if ($response->getStatusCode() !== 201) {
// Handle error.
}
// Note:
// - Use RequestBuilder::withPemFile() to provide a `\Yoti\Util\PemFile`
// - Use RequestBuilder::withPemString() to provide PEM string
import json
from yoti_python_sdk.http import SignedRequest
payload_data = {
"issuance_token": attribute_issuance_details.token,
"attributes": [
{
"name": "com.example.someAttribute",
"value": "some attribute value"
}
]
}
payload_string = json.dumps(payload_data).encode()
signed_request = (
SignedRequest
.builder()
.with_pem_file("/path/to/key.pem")
.with_base_url("https://api.yoti.com/api/v1/attribute-registry")
.with_endpoint("/attributes")
.with_http_method("POST")
.with_header("X-Yoti-Auth-Id", "CLIENT_SDK_ID")
.with_payload(payload_string)
.build()
)
response = signed_request.execute()
var attributeDefinition = new Yoti.Auth.Share.ThirdParty.AttributeDefinition(attributeIssuanceDetails.IssuingAttributes[0].Name);
var attributeValue = "chosenAttributeValue";
string serializedRequest = JsonConvert.SerializeObject(
new {
issuance_token = attributeIssuanceDetails.Token,
attributes = new[]
{
new {
name = _thirdPartyAttributeName,
value = "chosenAttributeValue" // if type==JSON, this needs to be base64-encoded
}
}
});
byte[] httpContent = System.Text.Encoding.UTF8.GetBytes(serializedRequest);
var signedRequest = new RequestBuilder()
.WithBaseUri(new Uri("https://api.yoti.com/api/v1/attribute-registry"))
.WithEndpoint("/attributes")
.WithHttpMethod(HttpMethod.Post)
.WithHeader("X-Yoti-Auth-Id", _clientSdkId)
.WithKeyPair(keyPair)
.WithContent(httpContent)
.Build();
var result = signedRequest.Execute(httpClient).Result;
if (!result.IsSuccessStatusCode)
throw new InvalidOperationException($"StatusCode: {result.StatusCode}, Content: {result.Content.ReadAsStringAsync().Result}");
type Attribute struct {
Name string `json:"name"`
Value string `json:"value"`
}
type Payload struct {
Token string `json:"token"`
Attributes []Attribute `json:"attributes"`
}
body, err := json.Marshal(Payload{
Token: issuingAttributes.Token(),
Attributes: []Attribute{
Attribute{
Name: "com.example.someAttribute",
Value: "some attribute value",
},
},
})
if err != nil {
panic(err)
}
headers := map[string][]string{
"X-Yoti-Auth-Id": []string{"CLIENT_SDK_ID"},
}
decodedKey, err := cryptoutil.ParseRSAKey(key)
if err != nil {
panic(err)
}
request, err := requests.SignedRequest{
Key: decodedKey,
HTTPMethod: http.MethodPost,
BaseURL: "https://api.yoti.com/api/v1/attribute-registry",
Endpoint: "/attributes",
Headers: headers,
Body: body,
}.Request()
if err != nil {
panic(err)
}
response, err := requests.Execute(&http.Client{}, request)
payload = {
issuance_token: attribute_issuance_details.token,
attributes: [
{
name: 'com.example.someAttribute',
value: 'some attribute value'
}
]
}
request = Yoti::Request
.builder
.with_base_url('https://api.yoti.com/api/v1/attribute-registry')
.with_http_method('POST')
.with_endpoint('attributes')
.with_payload(payload)
.with_header('X-Yoti-Auth-Id', Yoti.configuration.client_sdk_id)
.build
response = request.execute