# auth pydantic_v2.BaseModel
acquisition
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 85] b'grant_type=client_credentials&scope=read+write&audience=https%3A%2F%2Fapi.example.com'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-1] b''
  first call requests a token = b'ok'
  > GET https://api.example.com/oauth/scopes
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-1] b''
  second call shares it = b'ok'
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, content-length: 69] b'grant_type=client_credentials&client_id=pets&client_secret=se%3Acr+et'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-2] b''
  client secret post = b'ok'
  > POST https://tokens.example.com/oauth/token
    [host: tokens.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  token url override, never redirected ! AuthError: AuthError(operation_id='bearer', reason='oauth_error', status_code=307) [operation_id='bearer', status_code=307] oauth_error
  declared token url https://auth.example.com/token
  base without token url ! ConfigurationError reason=missing_value field_path=('token_url',)
  plain http token url ! ConfigurationError reason=insecure_url field_path=('token_url',)
  relative token url ! ConfigurationError reason=invalid_url field_path=('token_url',)
  public client ! ConfigurationError reason=forbidden_value field_path=('client_secret',)
  scope string ! ConfigurationError reason=invalid_value field_path=('scopes',)
  empty audience ! ConfigurationError reason=invalid_value field_path=('audience',)
  client secret of another type ! ConfigurationError reason=invalid_type field_path=('client_secret',)
  token client of another type ! ConfigurationError reason=invalid_type field_path=('http_client',)
  loopback http token url = 'OauthClientCredentials'
rejections
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-1] b''
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-2] b''
  invalid token renews once = b'ok'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-2] b''
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-3] b''
  a second rejection is final ! AuthenticationError: Error code: 401 [operation_id='oauth_read', status_code=401, body=b'', body_bytes=b'', truncated=False, cause=DecodeError()]
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-3] b''
  insufficient scope ! AuthenticationError: Error code: 401 [operation_id='oauth_read', status_code=401, body=b'', body_bytes=b'', truncated=False, cause=DecodeError()]
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-3] b''
  challenge-less 401 undeclared ! AuthenticationError: Error code: 401 [operation_id='oauth_read', status_code=401, body=b'', body_bytes=b'', truncated=False, cause=DecodeError()]
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/challenge-less
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-4] b''
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/challenge-less
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-5] b''
  challenge-less 401 declared = b'ok'
  > POST https://api.example.com/unsafe
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, content-type: application/octet-stream, content-length: 7, authorization: Bearer access-5] b'payload'
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > POST https://api.example.com/unsafe
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, content-type: application/octet-stream, content-length: 7, authorization: Bearer access-6] b'payload'
  replayable body = b'ok'
  > POST https://api.example.com/unsafe
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, content-type: application/octet-stream, transfer-encoding: chunked, authorization: Bearer access-6] b'payload'
  one-shot body ! AuthenticationError: Error code: 401 [operation_id='unsafe_auth', status_code=401, body=b'', body_bytes=b'', truncated=False, cause=DecodeError()]
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-7] b''
  > GET https://other.example.com/elsewhere
    [host: other.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream] b''
  rejection after a redirect ! AuthenticationError: Error code: 401 [operation_id='oauth_read', status_code=401, body=b'', body_bytes=b'', truncated=False, cause=DecodeError()]
faults
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  rejected client ! AuthError reason=oauth_error status_code=401 oauth_error=invalid_client
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  unknown error code ! AuthError reason=oauth_error status_code=400
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  server error ! AuthError reason=oauth_error status_code=503
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  not json ! AuthError reason=oauth_error status_code=200
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  another token type ! AuthError reason=oauth_error status_code=200
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  nonpositive expiry ! AuthError reason=invalid_expiry
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  boolean expiry ! AuthError reason=invalid_expiry
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  connect failure ! AuthError reason=oauth_error cause=ConnectError
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  read timeout ! AuthError reason=timeout cause=ReadTimeout
  secret callable failure ! AuthError reason=provider_failed cause=OSError
  secret callable's own error ! ConfigurationError reason=missing_value field_path=('vault',)
  secret callable of another type ! ConfigurationError reason=invalid_type field_path=('client_secret',)
  provider as a native auth without a token client ! ConfigurationError reason=missing_value field_path=('http_client',)
  > GET https://api.example.com/anonymous
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-native] b''
  provider as a call's native auth = b'ok'
  > GET https://api.example.com/anonymous
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-native] b''
  > GET https://api.example.com/anonymous
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-native-2] b''
  native auth renews once = b'ok'
  native token requests ['https://auth.example.com/token grant_type=client_credentials', 'https://auth.example.com/token grant_type=client_credentials']
  asyncio token client in a synchronous call ! ConfigurationError reason=invalid_mode field_path=('http_client',)
renewal
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-1] b''
  token of a hundred seconds = b'ok'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-1] b''
  before its renewal is due = b'ok'
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-1] b''
  failed early renewal keeps the token = b'ok'
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  failed renewal after expiry ! AuthError reason=oauth_error status_code=503
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-2] b''
  next call acquires again = b'ok'
token client
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-own] b''
  own token client = b'ok'
  token requests ['https://auth.example.com/token grant_type=client_credentials'] resource client saw ['https://api.example.com/oauth/read']
concurrency
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-shared] b''
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-shared] b''
  concurrent calls results=["b'one'", "b'two'"] token requests=1
async
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-a3] b''
  async token of a hundred seconds = b'ok'
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-a3] b''
  async failed early renewal keeps the token = b'ok'
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  async failed renewal after expiry ! AuthError reason=oauth_error cause=ConnectError
  synchronous token client in an asyncio call ! ConfigurationError reason=invalid_mode field_path=('http_client',)
  > GET https://api.example.com/anonymous
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-async-native] b''
  async provider as a call's native auth = b'ok'
  async native token requests ['https://auth.example.com/token grant_type=client_credentials']
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-a1] b''
  async first = b'ok'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-a1] b''
  > POST https://auth.example.com/token
    [host: auth.example.com, accept: application/json, content-type: application/x-www-form-urlencoded, authorization: Basic cGV0czpzZSUzQWNyK2V0, content-length: 29] b'grant_type=client_credentials'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-a2] b''
  async renewed = b'ok'
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-gathered] b''
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-gathered] b''
  async gathered=[b'ok', b'ok'] token requests=1
  async cancelled while its token request was held
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-after] b''
  async after cancellation = b'ok' token requests=1
event loops
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-loop1] b''
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-loop1] b''
  loop gathered=[b'ok', b'ok'] token requests=1
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-loop2] b''
  > GET https://api.example.com/oauth/read
    [host: api.example.com, accept-encoding: gzip, deflate, accept: application/octet-stream, authorization: Bearer access-loop2] b''
  loop gathered=[b'ok', b'ok'] token requests=2
