Onayı kullan
Onaylanmış bir isteği atomik olarak yalnızca bir kez kullanır. Korunan işlemi yapmadan hemen önce çağırın; tekrar gönderilen bir token ya da yeniden denenen form 409 already_used alır. SDK guard'ları (requireTouchque, relay router'lar, tq.complete) bunu sizin için çağırır.
POST/login/{id}/consume
| Durum | Anlam |
|---|---|
200 | Kullanıldı: kullanıcı, tip, detaylar, assurance, approvalProof |
409 | already_used · rejected · expired · not_approved |
404 | Sizin isteğiniz değil |
İstek
const { Touchque } = require('@touchque/node');
const tq = new Touchque({
apiKey: 'tq_abc123',
apiSecret: 'YOUR_API_SECRET'
});
// Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
// login.consume @touchque/node 5.2.0'da var; tq.complete(requestId, { user, action })
// tek çağrıda hem kullanır hem kontrol eder.
const approval = await tq.login.consume('request_id_here');
if (approval.externalUsername !== user || approval.type !== 'LOGIN') {
throw new Error('This approval is for another user or action');
}<?php
require_once 'vendor/autoload.php';
use Touchque\Touchque;
use Touchque\Config;
$tq = new Touchque(new Config('tq_abc123', 'YOUR_API_SECRET'));
// Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
$approval = $tq->login->consume('request_id_here');
if ($approval['externalUsername'] !== $user || $approval['type'] !== 'LOGIN') {
throw new RuntimeException('This approval is for another user or action');
}package main
import (
"fmt"
"log"
"github.com/Touchque/touchque-go/v5/touchque"
)
func main() {
tq, err := touchque.New(touchque.DefaultConfig("tq_abc123", "YOUR_API_SECRET"))
if err != nil {
log.Fatal(err)
}
// Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
approval, err := tq.Login.Consume("request_id_here")
if err != nil {
log.Fatal(err)
}
fmt.Println("Approved:", approval.ExternalUsername, approval.Type)
}from touchque import Touchque, Config
tq = Touchque(Config(api_key="tq_abc123", api_secret="YOUR_API_SECRET"))
# Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
approval = tq.login.consume("request_id_here")
if approval["externalUsername"] != user or approval["type"] != "LOGIN":
raise RuntimeError("This approval is for another user or action")var tq = new TouchqueClient(new TouchqueOptions { ApiKey = "tq_abc123", ApiSecret = "YOUR_API_SECRET" });
// Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
var approval = await tq.Login.ConsumeAsync("request_id_here");
if (approval.ExternalUsername != user || approval.Type != "LOGIN")
throw new InvalidOperationException("This approval is for another user or action");var tq = new TouchqueClient(new TouchqueOptions().apiKey("tq_abc123").apiSecret("YOUR_API_SECRET"));
// Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
JsonNode approval = tq.login().consume("request_id_here");
if (!approval.path("externalUsername").asText().equals(user) || !"LOGIN".equals(approval.path("type").asText())) {
throw new IllegalStateException("This approval is for another user or action");
}tq = Touchque::Client.new(api_key: "tq_abc123", api_secret: "YOUR_API_SECRET")
# Onayı yalnız bir kez kullanın: ikinci çağrı 'already_used' (409) hatası verir.
approval = tq.login.consume("request_id_here")
raise "This approval is for another user or action" if approval["externalUsername"] != user || approval["type"] != "LOGIN"curl -X POST https://api.touchque.com/login/<requestId>/consume \
-H "x-api-key: tq_abc123" -H "x-timestamp: $TS" -H "x-nonce: $NONCE" -H "x-signature: $SIG"Cevap 200
{
"consumed": true,
"requestId": "…",
"externalUsername": "user@yourcompany.com",
"type": "WITHDRAW",
"confirmedVia": "DEVICE",
"assurance": { "phishingResistant": false, "method": "push" },
"approvalProof": { "version": "v2", "…": "…" }
}