• Get Review Board
  • What's New
  • Products
  • Review Board Code review, image review, and document review
  • Documentation
  • Release Notes
  • Power Pack Enterprise integrations, reports, and enhanced document review
  • Try for 60 Days
  • Purchase
  • RBCommons Review Board as a Service, hosted by us
  • Pricing
  • RBTools Command line tools and Python API for Review Board
  • Documentation
  • Release Notes
  • Review Bot Automated code review, connecting tools you already use
  • Documentation
  • Release Notes
  • RB Gateway Manage Git and Mercurial repositories in your network
  • Documentation
  • Release Notes
  • Learn and Explore
  • What is Code Review?
  • Documentation
  • Frequently Asked Questions
  • Support Options
  • Third-Party Integrations
  • Demo
  • Review Board RBTools Power Pack Review Bot Djblets RB Gateway
    1. Djblets 4.x
    2. Version 5.x
    3. Version 4.x
    4. Version 3.x
    5. Version 2.x
    6. Version 2.0
    7. Version 1.0
    8. Version 0.9
    9. Djblets Documentation
    10. Module and Class References
    11. djblets.webapi.models
  • Home
  • Guides
  • Avatar Services Guides
  • Writing Avatar Services
  • Extension Guides
  • Writing Extensions
  • Testing Extensions
  • Feature Checks Guides
  • Introduction to Feature Checks
  • Writing Features
  • Writing Feature Checkers
  • Testing with Feature Checks
  • Integration Guides
  • Supporting Integrations
  • Writing Integrations
  • Privacy Compliance Guides
  • Getting and Checking Consent
  • Working with Personally Identifiable Information
  • Service Integrations
  • reCAPTCHA Guides
  • Using reCAPTCHA
  • Registries Guides
  • Writing Registries
  • Web API Guides
  • Writing Web API Resources
  • Adding OAuth2 Support
  • Module and Class References
  • djblets
  • djblets.deprecation
  • djblets.auth.forms
  • djblets.auth.ratelimit
  • djblets.auth.signals
  • djblets.auth.util
  • djblets.auth.views
  • djblets.avatars.errors
  • djblets.avatars.forms
  • djblets.avatars.registry
  • djblets.avatars.services
  • djblets.avatars.services.base
  • djblets.avatars.services.fallback
  • djblets.avatars.services.file_upload
  • djblets.avatars.services.gravatar
  • djblets.avatars.services.url
  • djblets.avatars.settings
  • djblets.cache.backend
  • djblets.cache.backend_compat
  • djblets.cache.context_processors
  • djblets.cache.errors
  • djblets.cache.forwarding_backend
  • djblets.cache.serials
  • djblets.cache.synchronizer
  • djblets.conditions
  • djblets.conditions.choices
  • djblets.conditions.conditions
  • djblets.conditions.errors
  • djblets.conditions.operators
  • djblets.conditions.values
  • djblets.configforms.forms
  • djblets.configforms.mixins
  • djblets.configforms.pages
  • djblets.configforms.registry
  • djblets.configforms.views
  • djblets.datagrid.grids
  • djblets.db.backends.mysql.base
  • djblets.db.fields
  • djblets.db.fields.base64_field
  • djblets.db.fields.counter_field
  • djblets.db.fields.json_field
  • djblets.db.fields.modification_timestamp_field
  • djblets.db.fields.relation_counter_field
  • djblets.db.managers
  • djblets.db.query
  • djblets.db.validators
  • djblets.extensions.admin
  • djblets.extensions.errors
  • djblets.extensions.extension
  • djblets.extensions.forms
  • djblets.extensions.hooks
  • djblets.extensions.loaders
  • djblets.extensions.manager
  • djblets.extensions.middleware
  • djblets.extensions.models
  • djblets.extensions.packaging
  • djblets.extensions.resources
  • djblets.extensions.settings
  • djblets.extensions.signals
  • djblets.extensions.staticfiles
  • djblets.extensions.testing
  • djblets.extensions.testing.testcases
  • djblets.extensions.urls
  • djblets.extensions.views
  • djblets.extensions.templatetags.djblets_extensions
  • djblets.features
  • djblets.features.checkers
  • djblets.features.decorators
  • djblets.features.errors
  • djblets.features.feature
  • djblets.features.level
  • djblets.features.registry
  • djblets.features.testing
  • djblets.features.templatetags.features
  • djblets.feedview.views
  • djblets.feedview.templatetags.feedtags
  • djblets.forms.fields
  • djblets.forms.fieldsets
  • djblets.forms.forms
  • djblets.forms.forms.key_value_form
  • djblets.forms.widgets
  • djblets.gravatars
  • djblets.gravatars.templatetags.gravatars
  • djblets.http.middleware
  • djblets.http.responses
  • djblets.integrations.errors
  • djblets.integrations.forms
  • djblets.integrations.hooks
  • djblets.integrations.integration
  • djblets.integrations.manager
  • djblets.integrations.mixins
  • djblets.integrations.models
  • djblets.integrations.urls
  • djblets.integrations.views
  • djblets.log
  • djblets.log.middleware
  • djblets.log.siteconfig
  • djblets.log.urls
  • djblets.log.views
  • djblets.mail.dmarc
  • djblets.mail.message
  • djblets.mail.testing
  • djblets.mail.utils
  • djblets.markdown
  • djblets.markdown.extensions.escape_html
  • djblets.markdown.extensions.wysiwyg
  • djblets.markdown.extensions.wysiwyg_email
  • djblets.pipeline.compilers.es6
  • djblets.pipeline.compilers.less
  • djblets.pipeline.compilers.mixins
  • djblets.pipeline.compilers.rollup
  • djblets.pipeline.compilers.typescript
  • djblets.pipeline.settings
  • djblets.privacy.consent
  • djblets.privacy.consent.base
  • djblets.privacy.consent.common
  • djblets.privacy.consent.errors
  • djblets.privacy.consent.forms
  • djblets.privacy.consent.hooks
  • djblets.privacy.consent.registry
  • djblets.privacy.consent.tracker
  • djblets.privacy.models
  • djblets.privacy.pii
  • djblets.privacy.templatetags.djblets_privacy
  • djblets.recaptcha.mixins
  • djblets.recaptcha.siteconfig
  • djblets.recaptcha.templatetags.djblets_recaptcha
  • djblets.recaptcha.widgets
  • djblets.registries
  • djblets.registries.errors
  • djblets.registries.importer
  • djblets.registries.mixins
  • djblets.registries.registry
  • djblets.registries.signals
  • djblets.secrets
  • djblets.secrets.crypto
  • djblets.secrets.token_generators
  • djblets.secrets.token_generators.base
  • djblets.secrets.token_generators.legacy_sha1
  • djblets.secrets.token_generators.registry
  • djblets.secrets.token_generators.vendor_checksum
  • djblets.siteconfig
  • djblets.siteconfig.admin
  • djblets.siteconfig.context_processors
  • djblets.siteconfig.django_settings
  • djblets.siteconfig.forms
  • djblets.siteconfig.managers
  • djblets.siteconfig.middleware
  • djblets.siteconfig.models
  • djblets.siteconfig.signals
  • djblets.siteconfig.views
  • djblets.template.caches
  • djblets.template.context
  • djblets.template.loaders.conditional_cached
  • djblets.template.loaders.namespaced_app_dirs
  • djblets.testing.decorators
  • djblets.testing.testcases
  • djblets.testing.testrunners
  • djblets.urls.context_processors
  • djblets.urls.decorators
  • djblets.urls.patterns
  • djblets.urls.resolvers
  • djblets.urls.root
  • djblets.urls.staticfiles
  • djblets.util.compat.django.core.cache
  • djblets.util.compat.python.past
  • djblets.util.contextmanagers
  • djblets.util.dates
  • djblets.util.decorators
  • djblets.util.filesystem
  • djblets.util.functional
  • djblets.util.html
  • djblets.util.http
  • djblets.util.humanize
  • djblets.util.json_utils
  • djblets.util.properties
  • djblets.util.serializers
  • djblets.util.symbols
  • djblets.util.templatetags.djblets_deco
  • djblets.util.templatetags.djblets_email
  • djblets.util.templatetags.djblets_forms
  • djblets.util.templatetags.djblets_images
  • djblets.util.templatetags.djblets_js
  • djblets.util.templatetags.djblets_utils
  • djblets.util.typing
  • djblets.util.views
  • djblets.views.generic.base
  • djblets.views.generic.etag
  • djblets.webapi.auth
  • djblets.webapi.auth.backends
  • djblets.webapi.auth.backends.api_tokens
  • djblets.webapi.auth.backends.base
  • djblets.webapi.auth.backends.basic
  • djblets.webapi.auth.backends.oauth2_tokens
  • djblets.webapi.auth.views
  • djblets.webapi.decorators
  • djblets.webapi.encoders
  • djblets.webapi.errors
  • djblets.webapi.fields
  • djblets.webapi.managers
  • djblets.webapi.models
  • djblets.webapi.oauth2_scopes
  • djblets.webapi.resources
  • djblets.webapi.resources.base
  • djblets.webapi.resources.group
  • djblets.webapi.resources.registry
  • djblets.webapi.resources.root
  • djblets.webapi.resources.user
  • djblets.webapi.resources.mixins.api_tokens
  • djblets.webapi.resources.mixins.forms
  • djblets.webapi.resources.mixins.oauth2_tokens
  • djblets.webapi.resources.mixins.queries
  • djblets.webapi.responses
  • djblets.webapi.signals
  • djblets.webapi.testing
  • djblets.webapi.testing.decorators
  • djblets.webapi.testing.testcases
  • General Index
  • Python Module Index
  • Release Notes
  • This documentation covers Djblets 4.x. You can select a version above or view the latest documentation.

    djblets.webapi.models¶

    class BaseWebAPIToken(*args, **kwargs)[source]¶

    Bases: Model

    Base class for an access token used for authenticating with the API.

    Each token can be used to authenticate the token’s owner with the API, without requiring a username or password to be provided. Tokens can be revoked, and new tokens added.

    Tokens can store policy information, which will later be used for restricting access to the API.

    user[source]¶

    Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

    In the example:

    class Child(Model):
        parent = ForeignKey(Parent, related_name='children')
    

    Child.parent is a ForwardManyToOneDescriptor instance.

    token[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    token_generator_id[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    time_added[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    last_updated[source]¶

    A descriptor for tracking the modification of a value.

    field_name¶

    The attribute name of the field on the model.

    Type:

    unicode

    state_name¶

    The attribute name of the state on the model.

    Type:

    unicode

    last_used[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    expires[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    valid[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    invalid_date[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    invalid_reason[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    note[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    policy[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    extra_data[source]¶

    A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

    is_accessible_by(user)[source]¶
    is_mutable_by(user)[source]¶
    is_deletable_by(user)[source]¶
    is_deprecated() → bool[source]¶

    Return whether the token is deprecated or not.

    This will be True if the token was generated by a deprecated token generator.

    New in version 3.1.

    Returns:

    Whether the token is deprecated.

    Return type:

    bool

    is_expired() → bool[source]¶

    Return whether the token is expired or not.

    This will be False if there is no expiration date set.

    New in version 3.0.

    Returns:

    Whether the token is expired.

    Return type:

    bool

    __str__()[source]¶

    Return str(self).

    save(*args, **kwargs)[source]¶

    Save the token.

    If the token is being updated, the webapi_token_updated signal will be emitted.

    Parameters:
    • *args (tuple) – Positional arguments to pass to the superclass.

    • **kwargs (dict) – Keyword arguments to pass to the superclass.

    classmethod get_root_resource()[source]¶
    classmethod validate_policy(policy)[source]¶

    Validate an API policy.

    This will check to ensure that the policy is in a suitable format and contains the information required in a format that can be parsed.

    If a failure is found, a ValidationError will be raised describing the error and where it was found.

    class Meta[source]¶

    Bases: object

    abstract = False[source]¶
    verbose_name = 'Web API token'[source]¶
    verbose_name_plural = 'Web API tokens'[source]¶
    __annotations__ = {}¶
    get_extra_data_json()¶
    get_next_by_last_updated(*, field=<djblets.db.fields.modification_timestamp_field.ModificationTimestampField: last_updated>, is_next=True, **kwargs)¶
    get_next_by_time_added(*, field=<django.db.models.fields.DateTimeField: time_added>, is_next=True, **kwargs)¶
    get_policy_json()¶
    get_previous_by_last_updated(*, field=<djblets.db.fields.modification_timestamp_field.ModificationTimestampField: last_updated>, is_next=False, **kwargs)¶
    get_previous_by_time_added(*, field=<django.db.models.fields.DateTimeField: time_added>, is_next=False, **kwargs)¶
    set_extra_data_json(json)¶
    set_policy_json(json)¶
    user_id¶

    Keep up with the latest Review Board releases, security updates, and helpful information.

    About
    News
    Demo
    RBCommons Hosting
    Integrations
    Happy Users
    Support Options
    Documentation
    FAQ
    User Manual
    RBTools
    Administration Guide
    Power Pack
    Release Notes
    Downloads
    Review Board
    RBTools
    Djblets
    Power Pack
    Package Store
    PGP Signatures
    Contributing
    Bug Tracker
    Submit Patches
    Development Setup
    Wiki
    Follow Us
    Mailing Lists
    Reddit
    Twitter
    Mastodon
    Facebook
    YouTube

    Copyright © 2006-2025 Beanbag, Inc. All rights reserved.

    Terms of Service — Privacy Policy — AI Ethics Policy — Branding

    On this page

    • [Top]
    • BaseWebAPIToken
      • BaseWebAPIToken.user
      • BaseWebAPIToken.token
      • BaseWebAPIToken.token_generator_id
      • BaseWebAPIToken.time_added
      • BaseWebAPIToken.last_updated
      • BaseWebAPIToken.field_name
      • BaseWebAPIToken.state_name
      • BaseWebAPIToken.last_used
      • BaseWebAPIToken.expires
      • BaseWebAPIToken.valid
      • BaseWebAPIToken.invalid_date
      • BaseWebAPIToken.invalid_reason
      • BaseWebAPIToken.note
      • BaseWebAPIToken.policy
      • BaseWebAPIToken.extra_data
      • BaseWebAPIToken.is_accessible_by()
      • BaseWebAPIToken.is_mutable_by()
      • BaseWebAPIToken.is_deletable_by()
      • BaseWebAPIToken.is_deprecated()
      • BaseWebAPIToken.is_expired()
      • BaseWebAPIToken.__str__()
      • BaseWebAPIToken.save()
      • BaseWebAPIToken.get_root_resource()
      • BaseWebAPIToken.validate_policy()
      • BaseWebAPIToken.Meta
        • BaseWebAPIToken.Meta.abstract
        • BaseWebAPIToken.Meta.verbose_name
        • BaseWebAPIToken.Meta.verbose_name_plural
      • BaseWebAPIToken.__annotations__
      • BaseWebAPIToken.get_extra_data_json()
      • BaseWebAPIToken.get_next_by_last_updated()
      • BaseWebAPIToken.get_next_by_time_added()
      • BaseWebAPIToken.get_policy_json()
      • BaseWebAPIToken.get_previous_by_last_updated()
      • BaseWebAPIToken.get_previous_by_time_added()
      • BaseWebAPIToken.set_extra_data_json()
      • BaseWebAPIToken.set_policy_json()
      • BaseWebAPIToken.user_id