Skip to content

xtr_security_oauth2_server.exception

The errors the bundle raises beside the library's.

Each derives from the library's :class:~xtr_security_oauth2_server_core.exception.OAuth2Error, so one except OAuth2Error still catches anything the library or the bundle raises.

  • :class:ClientAlreadyRegisteredError — an identifier a client was to be registered under that another client already holds.
  • :class:InvalidConfigurationError — a deployment's configuration the bundle cannot turn into a server, named setting by setting.

ClientAlreadyRegisteredError

ClientAlreadyRegisteredError(identifier: str)

Bases: OAuth2Error

A client could not be registered because its identifier is taken.

An identifier is what a client is known by at every endpoint, so two registrations cannot share one. Raised by whoever is registering — a command that looked first, a store that lost the race between the look and the write — and it carries the identifier and nothing else: what a store would say of a refused write names the row it refused, and a stored client's row carries the hash of its secret.

Report that identifier is already registered to a client.

InvalidConfigurationError

Bases: OAuth2Error, ValueError

A server cannot be built out of what a deployment configured.

An authorization server cannot be assembled out of defaults. It signs with a key only the deployment holds, seals its own payloads with another, says who it is in every token it mints, and reads its clients from a store somebody chose — and there is no safe stand-in for any of them. The bundle builds all the same, so a fresh application still runs its console; this is what the first service needing one of those settings raises, naming the setting and the file it belongs in.

Also raised for a setting that is present but cannot be used: an encryption key of an unknown kind, a default scope that is not among the available ones, a grant registered twice under one identifier, a store named under persistence.custom that nothing registered.

Deliberately not an OAuthServerError: no client caused this and no client is waiting for it. It derives from :class:OAuth2Error — one except OAuth2Error still catches everything this library raises — and from :class:ValueError, because a configuration this server cannot read is a bad argument, the same reason the security family's error of this name is one.