C#
using Auth0.ManagementApi;
using System.Threading.Tasks;
public partial class Examples
{
public async Task Example() {
var client = new ManagementApiClient(
token: "<token>",
clientOptions: new ClientOptions { BaseUrl = "https://{YOUR_DOMAIN}/api/v2" }
);
await client.Hooks.CreateAsync(
new CreateHookRequestContent {
Name = "name",
Script = "script",
TriggerId = HookTriggerIdEnum.CredentialsExchange
}
);
}
}package example
import (
context "context"
management "github.com/auth0/go-auth0/v2/management"
client "github.com/auth0/go-auth0/v2/management/client"
option "github.com/auth0/go-auth0/v2/management/option"
)
func do() {
mgmt, err := client.New(
"{YOUR_DOMAIN}",
option.WithToken(
"<token>",
),
)
if err != nil {
return
}
request := &management.CreateHookRequestContent{
Name: "name",
Script: "script",
TriggerId: management.HookTriggerIdEnumCredentialsExchange,
}
mgmt.Hooks.Create(
context.TODO(),
request,
)
}package com.example.usage;
import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.types.CreateHookRequestContent;
import com.auth0.client.mgmt.types.HookTriggerIdEnum;
public class Example {
public static void main(String[] args) {
ManagementApi client = ManagementApi
.builder()
.domain("{YOUR_DOMAIN}")
.token("<token>")
.build();
client.hooks().create(
CreateHookRequestContent
.builder()
.name("name")
.script("script")
.triggerId(HookTriggerIdEnum.CREDENTIALS_EXCHANGE)
.build()
);
}
}<?php
namespace Example;
use Auth0\SDK\API\Management\Wrapper\ManagementClient;
use Auth0\SDK\API\Management\Wrapper\ManagementClientOptions;
use Auth0\SDK\API\Management\Hooks\Requests\CreateHookRequestContent;
use Auth0\SDK\API\Management\Types\HookTriggerIdEnum;
$client = new ManagementClient(new ManagementClientOptions(
domain: '{YOUR_DOMAIN}',
token: '<token>',
));
$client->hooks->create(
new CreateHookRequestContent([
'name' => 'name',
'script' => 'script',
'triggerId' => HookTriggerIdEnum::CredentialsExchange->value,
]),
);from auth0.management import ManagementClient
client = ManagementClient(
domain="{YOUR_DOMAIN}",
token="<token>",
)
client.hooks.create(
name="name",
script="script",
trigger_id="credentials-exchange",
)require "auth0"
client = Auth0::Management.new(token: "<token>", base_url: "https://{YOUR_DOMAIN}/api/v2")
client.hooks.create(
name: "name",
script: "script",
trigger_id: "credentials-exchange"
)import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
domain: "{YOUR_DOMAIN}",
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({
domain: "{YOUR_DOMAIN}",
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); };",
"enabled": false,
"dependencies": {}
}
'{
"triggerId": "<string>",
"id": "00001",
"name": "hook",
"enabled": true,
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {}
}Create a hook
Create a new hook.
POST
https://{tenantDomain}/api/v2
/
hooks
C#
using Auth0.ManagementApi;
using System.Threading.Tasks;
public partial class Examples
{
public async Task Example() {
var client = new ManagementApiClient(
token: "<token>",
clientOptions: new ClientOptions { BaseUrl = "https://{YOUR_DOMAIN}/api/v2" }
);
await client.Hooks.CreateAsync(
new CreateHookRequestContent {
Name = "name",
Script = "script",
TriggerId = HookTriggerIdEnum.CredentialsExchange
}
);
}
}package example
import (
context "context"
management "github.com/auth0/go-auth0/v2/management"
client "github.com/auth0/go-auth0/v2/management/client"
option "github.com/auth0/go-auth0/v2/management/option"
)
func do() {
mgmt, err := client.New(
"{YOUR_DOMAIN}",
option.WithToken(
"<token>",
),
)
if err != nil {
return
}
request := &management.CreateHookRequestContent{
Name: "name",
Script: "script",
TriggerId: management.HookTriggerIdEnumCredentialsExchange,
}
mgmt.Hooks.Create(
context.TODO(),
request,
)
}package com.example.usage;
import com.auth0.client.mgmt.ManagementApi;
import com.auth0.client.mgmt.types.CreateHookRequestContent;
import com.auth0.client.mgmt.types.HookTriggerIdEnum;
public class Example {
public static void main(String[] args) {
ManagementApi client = ManagementApi
.builder()
.domain("{YOUR_DOMAIN}")
.token("<token>")
.build();
client.hooks().create(
CreateHookRequestContent
.builder()
.name("name")
.script("script")
.triggerId(HookTriggerIdEnum.CREDENTIALS_EXCHANGE)
.build()
);
}
}<?php
namespace Example;
use Auth0\SDK\API\Management\Wrapper\ManagementClient;
use Auth0\SDK\API\Management\Wrapper\ManagementClientOptions;
use Auth0\SDK\API\Management\Hooks\Requests\CreateHookRequestContent;
use Auth0\SDK\API\Management\Types\HookTriggerIdEnum;
$client = new ManagementClient(new ManagementClientOptions(
domain: '{YOUR_DOMAIN}',
token: '<token>',
));
$client->hooks->create(
new CreateHookRequestContent([
'name' => 'name',
'script' => 'script',
'triggerId' => HookTriggerIdEnum::CredentialsExchange->value,
]),
);from auth0.management import ManagementClient
client = ManagementClient(
domain="{YOUR_DOMAIN}",
token="<token>",
)
client.hooks.create(
name="name",
script="script",
trigger_id="credentials-exchange",
)require "auth0"
client = Auth0::Management.new(token: "<token>", base_url: "https://{YOUR_DOMAIN}/api/v2")
client.hooks.create(
name: "name",
script: "script",
trigger_id: "credentials-exchange"
)import { ManagementClient } from "auth0";
async function main() {
const client = new ManagementClient({
domain: "{YOUR_DOMAIN}",
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({
domain: "{YOUR_DOMAIN}",
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); };",
"enabled": false,
"dependencies": {}
}
'{
"triggerId": "<string>",
"id": "00001",
"name": "hook",
"enabled": true,
"script": "module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };",
"dependencies": {}
}承認
bearerAuthoAuth2ClientCredentials
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
ボディ
application/jsonapplication/x-www-form-urlencoded
Name of this 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); };
必須
Code to be executed when this hook runs.
Minimum string length:
1Execution stage of this rule. Can be credentials-exchange, pre-user-registration, post-user-registration, post-change-password, or send-phone-message.
利用可能なオプション:
credentials-exchange, pre-user-registration, post-user-registration, post-change-password, send-phone-message Whether this hook will be executed (true) or ignored (false).
Dependencies of this hook used by webtask server.
Show child attributes
Show child attributes
レスポンス
Hook successfully created.
Trigger ID
ID of this hook.
Name of this hook.
Whether this hook will be executed (true) or ignored (false).
script
string
デフォルト:module.exports = function(client, scope, audience, context, cb) cb(null, access_token); };
Code to be executed when this hook runs.
Dependencies of this hook used by webtask server.
Show child attributes
Show child attributes
⌘I