创建工作量证明挑战
curl --request POST \
--url https://api.qbank.cl/platform/v1/auth/pow-challenge \
--header 'Content-Type: application/json' \
--data '
{
"purpose": "register",
"email": "ana@example.com"
}
'import requests
url = "https://api.qbank.cl/platform/v1/auth/pow-challenge"
payload = {
"purpose": "register",
"email": "ana@example.com"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({purpose: 'register', email: 'ana@example.com'})
};
fetch('https://api.qbank.cl/platform/v1/auth/pow-challenge', 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://api.qbank.cl/platform/v1/auth/pow-challenge",
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([
'purpose' => 'register',
'email' => 'ana@example.com'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://api.qbank.cl/platform/v1/auth/pow-challenge"
payload := strings.NewReader("{\n \"purpose\": \"register\",\n \"email\": \"ana@example.com\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.qbank.cl/platform/v1/auth/pow-challenge")
.header("Content-Type", "application/json")
.body("{\n \"purpose\": \"register\",\n \"email\": \"ana@example.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qbank.cl/platform/v1/auth/pow-challenge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"purpose\": \"register\",\n \"email\": \"ana@example.com\"\n}"
response = http.request(request)
puts response.read_body{
"challenge": "eyJjaGFsbGVuZ2UiOiJleGFtcGxlIn0.sig",
"difficulty": 20,
"algorithm": "sha256-leading-zero-bits-v1",
"expires_in": 600,
"input": "sha256(nonce_bytes || lowercase(email) || be64(suffix)); find suffix with difficulty leading zero bits",
"nonce_bytes": "first 16 bytes of the base64url payload (part before the dot)"
}{
"error": "invalid_request",
"message": "purpose must be register, confirm or oauth and email must be valid"
}创建工作量证明挑战
为公开注册、注册确认或社交注册创建短期工作量证明挑战。挑战会绑定到请求中提供的用途、邮箱(如提供还有组织)。签发有按 IP 限流,与注册共享额度。
POST
/
v1
/
auth
/
pow-challenge
创建工作量证明挑战
curl --request POST \
--url https://api.qbank.cl/platform/v1/auth/pow-challenge \
--header 'Content-Type: application/json' \
--data '
{
"purpose": "register",
"email": "ana@example.com"
}
'import requests
url = "https://api.qbank.cl/platform/v1/auth/pow-challenge"
payload = {
"purpose": "register",
"email": "ana@example.com"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({purpose: 'register', email: 'ana@example.com'})
};
fetch('https://api.qbank.cl/platform/v1/auth/pow-challenge', 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://api.qbank.cl/platform/v1/auth/pow-challenge",
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([
'purpose' => 'register',
'email' => 'ana@example.com'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://api.qbank.cl/platform/v1/auth/pow-challenge"
payload := strings.NewReader("{\n \"purpose\": \"register\",\n \"email\": \"ana@example.com\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.qbank.cl/platform/v1/auth/pow-challenge")
.header("Content-Type", "application/json")
.body("{\n \"purpose\": \"register\",\n \"email\": \"ana@example.com\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qbank.cl/platform/v1/auth/pow-challenge")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"purpose\": \"register\",\n \"email\": \"ana@example.com\"\n}"
response = http.request(request)
puts response.read_body{
"challenge": "eyJjaGFsbGVuZ2UiOiJleGFtcGxlIn0.sig",
"difficulty": 20,
"algorithm": "sha256-leading-zero-bits-v1",
"expires_in": 600,
"input": "sha256(nonce_bytes || lowercase(email) || be64(suffix)); find suffix with difficulty leading zero bits",
"nonce_bytes": "first 16 bytes of the base64url payload (part before the dot)"
}{
"error": "invalid_request",
"message": "purpose must be register, confirm or oauth and email must be valid"
}请求体
application/json
purpose 为 oauth 时,使用身份标识 provider:subject@oauth.local(见 POST /v1/auth/oauth)。