Passer au contenu principal
GET
https://{tenantDomain}/api/v2
/
rules
Go
package example

import (
    client "github.com/auth0/go-auth0/management/client"
    option "github.com/auth0/go-auth0/management/option"
    context "context"
    management "github.com/auth0/go-auth0/management"
)

func do() () {
    client := client.NewClient(
        option.WithToken(
            "<token>",
        ),
    )
    client.Rules.List(
        context.TODO(),
        &management.ListRulesRequestParameters{
            Page: management.Int(
                1,
            ),
            PerPage: management.Int(
                1,
            ),
            IncludeTotals: management.Bool(
                true,
            ),
            Enabled: management.Bool(
                true,
            ),
            Fields: management.String(
                "fields",
            ),
            IncludeFields: management.Bool(
                true,
            ),
        },
    )
}
[
  {
    "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 requête

page
integer

Page index of the results to return. First page is 0.

Plage requise: x >= 0
per_page
integer

Number of results per page.

Plage requise: 0 <= x <= 100
include_totals
boolean

Return results inside an object that contains the total result count (true) or as a direct array of results (false, default).

enabled
boolean

Optional filter on whether a rule is enabled (true) or disabled (false).

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.

Pattern: ^((name)|(enabled)|(script)|(order)|(id)|(stage))(,((name)|(enabled)|(script)|(order)|(id)|(stage)))*$
include_fields
boolean

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

Réponse

Rules 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.