Go
package example
import (
context "context"
management "github.com/auth0/go-auth0/management/management"
client "github.com/auth0/go-auth0/management/management/client"
option "github.com/auth0/go-auth0/management/management/option"
)
func do() {
client := client.NewClient(
option.WithToken(
"<token>",
),
)
request := &management.CreateHookRequestContent{
Name: "name",
Script: "script",
TriggerId: management.HookTriggerIdEnumCredentialsExchange,
}
client.Hooks.Create(
context.TODO(),
request,
)
}import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.create({
name: "name",
script: "script",
triggerId: "credentials-exchange",
});
}
main();import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.create({
name: "name",
script: "script",
triggerId: "credentials-exchange",
});
}
main();curl --request POST \
--url https://{tenantDomain}/api/v2/hooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {},
"enabled": false
}
'import requests
url = "https://{tenantDomain}/api/v2/hooks"
payload = {
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {},
"enabled": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/hooks",
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([
'name' => 'my-hook',
'script' => 'module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };',
'dependencies' => [
],
'enabled' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://{tenantDomain}/api/v2/hooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"dependencies\": {},\n \"enabled\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenantDomain}/api/v2/hooks")
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/json'
request.body = "{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"dependencies\": {},\n \"enabled\": false\n}"
response = http.request(request)
puts response.read_body{
"dependencies": {},
"enabled": true,
"id": "00001",
"name": "hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"triggerId": "<string>"
}Hooks を作成
新しい Hook を作成します。
POST
https://{tenantDomain}/api/v2
/
hooks
Go
package example
import (
context "context"
management "github.com/auth0/go-auth0/management/management"
client "github.com/auth0/go-auth0/management/management/client"
option "github.com/auth0/go-auth0/management/management/option"
)
func do() {
client := client.NewClient(
option.WithToken(
"<token>",
),
)
request := &management.CreateHookRequestContent{
Name: "name",
Script: "script",
TriggerId: management.HookTriggerIdEnumCredentialsExchange,
}
client.Hooks.Create(
context.TODO(),
request,
)
}import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.create({
name: "name",
script: "script",
triggerId: "credentials-exchange",
});
}
main();import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.hooks.create({
name: "name",
script: "script",
triggerId: "credentials-exchange",
});
}
main();curl --request POST \
--url https://{tenantDomain}/api/v2/hooks \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {},
"enabled": false
}
'import requests
url = "https://{tenantDomain}/api/v2/hooks"
payload = {
"name": "my-hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {},
"enabled": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/hooks",
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([
'name' => 'my-hook',
'script' => 'module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };',
'dependencies' => [
],
'enabled' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://{tenantDomain}/api/v2/hooks")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"dependencies\": {},\n \"enabled\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenantDomain}/api/v2/hooks")
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/json'
request.body = "{\n \"name\": \"my-hook\",\n \"script\": \"module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };\",\n \"dependencies\": {},\n \"enabled\": false\n}"
response = http.request(request)
puts response.read_body{
"dependencies": {},
"enabled": true,
"id": "00001",
"name": "hook",
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"triggerId": "<string>"
}承認
bearerAuthoAuth2ClientCredentials
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
ボディ
application/jsonapplication/x-www-form-urlencoded
この Hook の名前。
Pattern:
^[a-zA-Z0-9]([ \-a-zA-Z0-9]*[a-zA-Z0-9])?$script
string
デフォルト:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
必須
この Hook の実行時に実行されるコード。
Minimum string length:
1この Rule の実行ステージ。credentials-exchange、pre-user-registration、post-user-registration、post-change-password、または send-phone-message を指定できます。
利用可能なオプション:
credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message webtaskサーバーで使用される、このHookの依存関係。
Show child attributes
Show child attributes
この Hook を実行するか(true)、無視するか(false)を示します。
レスポンス
Hook が正常に作成されました。
webtaskサーバーで使用される、このHookの依存関係。
Show child attributes
Show child attributes
この Hook を実行するか(true)、無視するか(false)を示します。
この Hook の ID。
この Hook の名前。
script
string
デフォルト:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
この Hook の実行時に実行されるコード。
トリガー ID
⌘I