Passer au contenu principal
GET
https://{tenantDomain}/api/v2
/
rules
/
{id}
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.GetRuleRequestParameters{
        Fields: management.String(
            "fields",
        ),
        IncludeFields: management.Bool(
            true,
        ),
    }
    client.Rules.Get(
        context.TODO(),
        "id",
        request,
    )
}
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.rules.get("id", {
fields: "fields",
includeFields: true,
});
}
main();
import { ManagementClient } from "auth0";

async function main() {
const client = new ManagementClient({
token: "<token>",
});
await client.rules.get("id", {
fields: "fields",
includeFields: true,
});
}
main();
curl --request GET \
--url https://{tenantDomain}/api/v2/rules/{id} \
--header 'Authorization: Bearer <token>'
import requests

url = "https://{tenantDomain}/api/v2/rules/{id}"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenantDomain}/api/v2/rules/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
HttpResponse<String> response = Unirest.get("https://{tenantDomain}/api/v2/rules/{id}")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{tenantDomain}/api/v2/rules/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "name": "rule_1",
  "id": "con_0000000000000001",
  "enabled": true,
  "script": "function (user, context, callback) {\n  callback(null, user, context);\n}",
  "order": 1,
  "stage": "login_success"
}

Autorisations

Authorization
string
header
requis

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Paramètres de chemin

id
string
requis

ID of the rule to retrieve.

Paramètres de requête

fields
string

Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields.

include_fields
boolean

Whether specified fields are to be included (true) or excluded (false).

Réponse

Rule successfully retrieved.

name
string
défaut:rule_1

Name of this rule.

id
string
défaut:con_0000000000000001

ID of this rule.

enabled
boolean
défaut:true

Whether the rule is enabled (true), or disabled (false).

script
string
défaut:function (user, context, callback) { callback(null, user, context); }

Code to be executed when this rule runs.

order
number
défaut:1

Order that this rule should execute in relative to other rules. Lower-valued rules execute first.

stage
string
défaut:login_success

Execution stage of this rule. Can be login_success, login_failure, or pre_authorize.