OAuth2 token

OAuth2.0 refresh token middleware.

class blacksmith.middleware._async.oauth2_token.GetToken(*, content_type: str = 'application/x-www-form-urlencoded', client_id: str | UUID, client_secret: SecretStr, grant_type: Literal['refresh_token'], refresh_token: SecretStr)
content_type: str
client_id: str | UUID
client_secret: SecretStr
grant_type: Literal['refresh_token']
refresh_token: SecretStr
__pydantic_fields_set__

The names of fields explicitly set during instantiation.

__pydantic_extra__

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_private__

Values of private attributes set on the model instance.

__class_vars__ = {}

The names of the class variables defined on the model.

__private_attributes__ = {}

Metadata about the private attributes of the model.

__pydantic_complete__ = True

Whether model building is completed, or if there are still undefined fields.

__pydantic_computed_fields__ = {}

A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.

__pydantic_core_schema__ = {'cls': <class 'blacksmith.middleware._async.oauth2_token.GetToken'>, 'config': {'title': 'GetToken'}, 'custom_init': False, 'metadata': {'pydantic_js_functions': [<bound method BaseModel.__get_pydantic_json_schema__ of <class 'blacksmith.middleware._async.oauth2_token.GetToken'>>]}, 'ref': 'blacksmith.middleware._async.oauth2_token.GetToken:94038288279104', 'root_model': False, 'schema': {'computed_fields': [], 'fields': {'client_id': {'metadata': {'pydantic_js_extra': {'location': 'body'}}, 'schema': {'choices': [{'type': 'str'}, {'type': 'uuid'}], 'type': 'union'}, 'type': 'model-field'}, 'client_secret': {'metadata': {'pydantic_js_extra': {'location': 'body'}}, 'schema': {'lax_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'metadata': {'pydantic_js_functions': [<function _SecretField.__get_pydantic_core_schema__.<locals>.get_json_schema>]}, 'strict_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'type': 'lax-or-strict'}, 'type': 'model-field'}, 'content_type': {'metadata': {'pydantic_js_extra': {'location': 'header'}}, 'schema': {'default': 'application/x-www-form-urlencoded', 'schema': {'type': 'str'}, 'type': 'default'}, 'serialization_alias': 'Content-Type', 'type': 'model-field', 'validation_alias': 'Content-Type'}, 'grant_type': {'metadata': {'pydantic_js_extra': {'location': 'body'}}, 'schema': {'expected': ['refresh_token'], 'type': 'literal'}, 'type': 'model-field'}, 'refresh_token': {'metadata': {'pydantic_js_extra': {'location': 'body'}}, 'schema': {'lax_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'metadata': {'pydantic_js_functions': [<function _SecretField.__get_pydantic_core_schema__.<locals>.get_json_schema>]}, 'strict_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'type': 'lax-or-strict'}, 'type': 'model-field'}}, 'model_name': 'GetToken', 'type': 'model-fields'}, 'type': 'model'}

The core schema of the model.

__pydantic_custom_init__ = False

Whether the model has a custom __init__ method.

__pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_fields__ = {'client_id': FieldInfo(annotation=Union[str, UUID], required=True, json_schema_extra={'location': 'body'}), 'client_secret': FieldInfo(annotation=SecretStr, required=True, json_schema_extra={'location': 'body'}), 'content_type': FieldInfo(annotation=str, required=False, default='application/x-www-form-urlencoded', alias='Content-Type', alias_priority=2, json_schema_extra={'location': 'header'}), 'grant_type': FieldInfo(annotation=Literal['refresh_token'], required=True, json_schema_extra={'location': 'body'}), 'refresh_token': FieldInfo(annotation=SecretStr, required=True, json_schema_extra={'location': 'body'})}

A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects. This replaces Model.__fields__ from Pydantic V1.

__pydantic_generic_metadata__ = {'args': (), 'origin': None, 'parameters': ()}

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__ = None

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__ = None

The name of the post-init method for the model, if defined.

__pydantic_serializer__ = SchemaSerializer(serializer=Model(     ModelSerializer {         class: Py(             0x00005586fec4a640,         ),         serializer: Fields(             GeneralFieldsSerializer {                 fields: {                     "client_secret": SerField {                         key_py: Py(                             0x00007f107959fbb0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             Function(                                 FunctionPlainSerializer {                                     func: Py(                                         0x00007f107a7edc60,                                     ),                                     name: "plain_function[_serialize_secret_field]",                                     function_name: "_serialize_secret_field",                                     return_serializer: Any(                                         AnySerializer,                                     ),                                     fallback_serializer: None,                                     when_used: Always,                                     is_field_serializer: false,                                     info_arg: true,                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                     "client_id": SerField {                         key_py: Py(                             0x00007f107959fbf0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             Union(                                 UnionSerializer {                                     choices: [                                         Str(                                             StrSerializer,                                         ),                                         Uuid(                                             UuidSerializer,                                         ),                                     ],                                     name: "Union[str, uuid]",                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                     "refresh_token": SerField {                         key_py: Py(                             0x00007f10799ffdb0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             Function(                                 FunctionPlainSerializer {                                     func: Py(                                         0x00007f107a7edc60,                                     ),                                     name: "plain_function[_serialize_secret_field]",                                     function_name: "_serialize_secret_field",                                     return_serializer: Any(                                         AnySerializer,                                     ),                                     fallback_serializer: None,                                     when_used: Always,                                     is_field_serializer: false,                                     info_arg: true,                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                     "content_type": SerField {                         key_py: Py(                             0x00007f107ab71e70,                         ),                         alias: Some(                             "Content-Type",                         ),                         alias_py: Some(                             Py(                                 0x00007f10796025b0,                             ),                         ),                         serializer: Some(                             WithDefault(                                 WithDefaultSerializer {                                     default: Default(                                         Py(                                             0x00007f1079610d00,                                         ),                                     ),                                     serializer: Str(                                         StrSerializer,                                     ),                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                     "grant_type": SerField {                         key_py: Py(                             0x00007f107959ebf0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             Literal(                                 LiteralSerializer {                                     expected_int: {},                                     expected_str: {                                         "refresh_token",                                     },                                     expected_py: None,                                     name: "literal['refresh_token']",                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                 },                 computed_fields: Some(                     ComputedFields(                         [],                     ),                 ),                 mode: SimpleDict,                 extra_serializer: None,                 filter: SchemaFilter {                     include: None,                     exclude: None,                 },                 required_fields: 5,             },         ),         has_extra: false,         root_model: false,         name: "GetToken",     }, ), definitions=[])

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_setattr_handlers__ = {}

__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__

__pydantic_validator__ = SchemaValidator(title="GetToken", validator=Model(     ModelValidator {         revalidate: Never,         validator: ModelFields(             ModelFieldsValidator {                 fields: [                     Field {                         name: "content_type",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "content_type",                                         py_key: Py(                                             0x00007f1079601770,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: Some(                                 Simple(                                     LookupPath {                                         first_item: PathItemString {                                             key: "Content-Type",                                             py_key: Py(                                                 0x00007f107959fc30,                                             ),                                         },                                         rest: [],                                     },                                 ),                             ),                             by_alias_then_name: Some(                                 Choice {                                     path1: LookupPath {                                         first_item: PathItemString {                                             key: "Content-Type",                                             py_key: Py(                                                 0x00007f107959fc30,                                             ),                                         },                                         rest: [],                                     },                                     path2: LookupPath {                                         first_item: PathItemString {                                             key: "content_type",                                             py_key: Py(                                                 0x00007f10796016f0,                                             ),                                         },                                         rest: [],                                     },                                 },                             ),                         },                         name_py: Py(                             0x00007f107ab71e70,                         ),                         validator: WithDefault(                             WithDefaultValidator {                                 default: Default(                                     Py(                                         0x00007f1079610d00,                                     ),                                 ),                                 on_error: Raise,                                 validator: Str(                                     StrValidator {                                         strict: false,                                         coerce_numbers_to_str: false,                                     },                                 ),                                 validate_default: false,                                 copy_default: false,                                 name: "default[str]",                                 undefined: Py(                                     0x00007f107b128510,                                 ),                             },                         ),                         frozen: false,                     },                     Field {                         name: "client_id",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "client_id",                                         py_key: Py(                                             0x00007f10796024f0,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f107959fbf0,                         ),                         validator: Union(                             UnionValidator {                                 mode: Smart,                                 choices: [                                     (                                         Str(                                             StrValidator {                                                 strict: false,                                                 coerce_numbers_to_str: false,                                             },                                         ),                                         None,                                     ),                                     (                                         Uuid(                                             UuidValidator {                                                 strict: false,                                                 version: None,                                             },                                         ),                                         None,                                     ),                                 ],                                 custom_error: None,                                 name: "union[str,uuid]",                             },                         ),                         frozen: false,                     },                     Field {                         name: "client_secret",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "client_secret",                                         py_key: Py(                                             0x00007f1079601670,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f107959fbb0,                         ),                         validator: LaxOrStrict(                             LaxOrStrictValidator {                                 strict: false,                                 lax_validator: JsonOrPython(                                     JsonOrPython {                                         json: FunctionAfter(                                             FunctionAfterValidator {                                                 validator: Str(                                                     StrValidator {                                                         strict: false,                                                         coerce_numbers_to_str: false,                                                     },                                                 ),                                                 func: Py(                                                     0x00005586fe456a10,                                                 ),                                                 config: Py(                                                     0x00007f1079601740,                                                 ),                                                 name: "function-after[SecretStr(), str]",                                                 field_name: None,                                                 info_arg: false,                                             },                                         ),                                         python: Union(                                             UnionValidator {                                                 mode: Smart,                                                 choices: [                                                     (                                                         IsInstance(                                                             IsInstanceValidator {                                                                 class: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 class_repr: "SecretStr",                                                                 name: "is-instance[SecretStr]",                                                             },                                                         ),                                                         None,                                                     ),                                                     (                                                         FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: false,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079601740,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         None,                                                     ),                                                 ],                                                 custom_error: Some(                                                     KnownError(                                                         PydanticKnownError {                                                             error_type: StringType {                                                                 context: None,                                                             },                                                         },                                                     ),                                                 ),                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                             },                                         ),                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                     },                                 ),                                 strict_validator: JsonOrPython(                                     JsonOrPython {                                         json: FunctionAfter(                                             FunctionAfterValidator {                                                 validator: Str(                                                     StrValidator {                                                         strict: true,                                                         coerce_numbers_to_str: false,                                                     },                                                 ),                                                 func: Py(                                                     0x00005586fe456a10,                                                 ),                                                 config: Py(                                                     0x00007f1079601740,                                                 ),                                                 name: "function-after[SecretStr(), str]",                                                 field_name: None,                                                 info_arg: false,                                             },                                         ),                                         python: Union(                                             UnionValidator {                                                 mode: Smart,                                                 choices: [                                                     (                                                         IsInstance(                                                             IsInstanceValidator {                                                                 class: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 class_repr: "SecretStr",                                                                 name: "is-instance[SecretStr]",                                                             },                                                         ),                                                         None,                                                     ),                                                     (                                                         FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: true,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079601740,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         None,                                                     ),                                                 ],                                                 custom_error: Some(                                                     KnownError(                                                         PydanticKnownError {                                                             error_type: StringType {                                                                 context: None,                                                             },                                                         },                                                     ),                                                 ),                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                             },                                         ),                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                     },                                 ),                                 name: "lax-or-strict[lax=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]],strict=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]]",                             },                         ),                         frozen: false,                     },                     Field {                         name: "grant_type",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "grant_type",                                         py_key: Py(                                             0x00007f1079602530,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f107959ebf0,                         ),                         validator: Literal(                             LiteralValidator {                                 lookup: LiteralLookup {                                     expected_bool: None,                                     expected_int: None,                                     expected_str: Some(                                         {                                             "refresh_token": 0,                                         },                                     ),                                     expected_py_dict: None,                                     expected_py_values: None,                                     expected_py_primitives: Some(                                         Py(                                             0x00007f1079601580,                                         ),                                     ),                                     values: [                                         Py(                                             0x00007f10799ffdb0,                                         ),                                     ],                                 },                                 expected_repr: "'refresh_token'",                                 name: "literal['refresh_token']",                             },                         ),                         frozen: false,                     },                     Field {                         name: "refresh_token",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "refresh_token",                                         py_key: Py(                                             0x00007f1079602570,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f10799ffdb0,                         ),                         validator: LaxOrStrict(                             LaxOrStrictValidator {                                 strict: false,                                 lax_validator: JsonOrPython(                                     JsonOrPython {                                         json: FunctionAfter(                                             FunctionAfterValidator {                                                 validator: Str(                                                     StrValidator {                                                         strict: false,                                                         coerce_numbers_to_str: false,                                                     },                                                 ),                                                 func: Py(                                                     0x00005586fe456a10,                                                 ),                                                 config: Py(                                                     0x00007f1079601740,                                                 ),                                                 name: "function-after[SecretStr(), str]",                                                 field_name: None,                                                 info_arg: false,                                             },                                         ),                                         python: Union(                                             UnionValidator {                                                 mode: Smart,                                                 choices: [                                                     (                                                         IsInstance(                                                             IsInstanceValidator {                                                                 class: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 class_repr: "SecretStr",                                                                 name: "is-instance[SecretStr]",                                                             },                                                         ),                                                         None,                                                     ),                                                     (                                                         FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: false,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079601740,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         None,                                                     ),                                                 ],                                                 custom_error: Some(                                                     KnownError(                                                         PydanticKnownError {                                                             error_type: StringType {                                                                 context: None,                                                             },                                                         },                                                     ),                                                 ),                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                             },                                         ),                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                     },                                 ),                                 strict_validator: JsonOrPython(                                     JsonOrPython {                                         json: FunctionAfter(                                             FunctionAfterValidator {                                                 validator: Str(                                                     StrValidator {                                                         strict: true,                                                         coerce_numbers_to_str: false,                                                     },                                                 ),                                                 func: Py(                                                     0x00005586fe456a10,                                                 ),                                                 config: Py(                                                     0x00007f1079601740,                                                 ),                                                 name: "function-after[SecretStr(), str]",                                                 field_name: None,                                                 info_arg: false,                                             },                                         ),                                         python: Union(                                             UnionValidator {                                                 mode: Smart,                                                 choices: [                                                     (                                                         IsInstance(                                                             IsInstanceValidator {                                                                 class: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 class_repr: "SecretStr",                                                                 name: "is-instance[SecretStr]",                                                             },                                                         ),                                                         None,                                                     ),                                                     (                                                         FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: true,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079601740,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         None,                                                     ),                                                 ],                                                 custom_error: Some(                                                     KnownError(                                                         PydanticKnownError {                                                             error_type: StringType {                                                                 context: None,                                                             },                                                         },                                                     ),                                                 ),                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                             },                                         ),                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                     },                                 ),                                 name: "lax-or-strict[lax=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]],strict=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]]",                             },                         ),                         frozen: false,                     },                 ],                 model_name: "GetToken",                 extra_behavior: Ignore,                 extras_validator: None,                 extras_keys_validator: None,                 strict: false,                 from_attributes: false,                 loc_by_alias: true,                 validate_by_alias: None,                 validate_by_name: None,             },         ),         class: Py(             0x00005586fec4a640,         ),         generic_origin: None,         post_init: None,         frozen: false,         custom_init: false,         root_model: false,         undefined: Py(             0x00007f107b128510,         ),         name: "GetToken",     }, ), definitions=[], cache_strings=True)

The pydantic-core SchemaValidator used to validate instances of the model.

__signature__ = <Signature (*, content_type: str = 'application/x-www-form-urlencoded', client_id: str | uuid.UUID, client_secret: pydantic.types.SecretStr, grant_type: Literal['refresh_token'], refresh_token: pydantic.types.SecretStr) -> None>

The synthesized __init__ [Signature][inspect.Signature] of the model.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class blacksmith.middleware._async.oauth2_token.Token(*, expires_in: int, access_token: SecretStr, refresh_token: SecretStr | None = None)
expires_in: int
access_token: SecretStr
refresh_token: SecretStr | None
__pydantic_fields_set__

The names of fields explicitly set during instantiation.

__pydantic_extra__

A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to ‘allow’.

__pydantic_private__

Values of private attributes set on the model instance.

__class_vars__ = {}

The names of the class variables defined on the model.

__private_attributes__ = {}

Metadata about the private attributes of the model.

__pydantic_complete__ = True

Whether model building is completed, or if there are still undefined fields.

__pydantic_computed_fields__ = {}

A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.

__pydantic_core_schema__ = {'cls': <class 'blacksmith.middleware._async.oauth2_token.Token'>, 'config': {'title': 'Token'}, 'custom_init': False, 'metadata': {'pydantic_js_functions': [<bound method BaseModel.__get_pydantic_json_schema__ of <class 'blacksmith.middleware._async.oauth2_token.Token'>>]}, 'ref': 'blacksmith.middleware._async.oauth2_token.Token:94038287929824', 'root_model': False, 'schema': {'computed_fields': [], 'fields': {'access_token': {'metadata': {}, 'schema': {'lax_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'metadata': {'pydantic_js_functions': [<function _SecretField.__get_pydantic_core_schema__.<locals>.get_json_schema>]}, 'strict_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'type': 'lax-or-strict'}, 'type': 'model-field'}, 'expires_in': {'metadata': {}, 'schema': {'type': 'int'}, 'type': 'model-field'}, 'refresh_token': {'metadata': {}, 'schema': {'default': None, 'schema': {'schema': {'lax_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': False, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'metadata': {'pydantic_js_functions': [<function _SecretField.__get_pydantic_core_schema__.<locals>.get_json_schema>]}, 'strict_schema': {'json_schema': {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}, 'python_schema': {'choices': [{'cls': <class 'pydantic.types.SecretStr'>, 'type': 'is-instance'}, {'function': {'function': <class 'pydantic.types.SecretStr'>, 'type': 'no-info'}, 'schema': {'strict': True, 'type': 'str'}, 'type': 'function-after'}], 'custom_error_type': 'string_type', 'type': 'union'}, 'serialization': {'function': <function _serialize_secret_field>, 'info_arg': True, 'type': 'function-plain'}, 'type': 'json-or-python'}, 'type': 'lax-or-strict'}, 'type': 'nullable'}, 'type': 'default'}, 'type': 'model-field'}}, 'model_name': 'Token', 'type': 'model-fields'}, 'type': 'model'}

The core schema of the model.

__pydantic_custom_init__ = False

Whether the model has a custom __init__ method.

__pydantic_decorators__ = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})

Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.

__pydantic_fields__ = {'access_token': FieldInfo(annotation=SecretStr, required=True), 'expires_in': FieldInfo(annotation=int, required=True), 'refresh_token': FieldInfo(annotation=Union[SecretStr, NoneType], required=False, default=None)}

A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects. This replaces Model.__fields__ from Pydantic V1.

__pydantic_generic_metadata__ = {'args': (), 'origin': None, 'parameters': ()}

Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.

__pydantic_parent_namespace__ = None

Parent namespace of the model, used for automatic rebuilding of models.

__pydantic_post_init__ = None

The name of the post-init method for the model, if defined.

__pydantic_serializer__ = SchemaSerializer(serializer=Model(     ModelSerializer {         class: Py(             0x00005586febf51e0,         ),         serializer: Fields(             GeneralFieldsSerializer {                 fields: {                     "refresh_token": SerField {                         key_py: Py(                             0x00007f10799ffdb0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             WithDefault(                                 WithDefaultSerializer {                                     default: Default(                                         Py(                                             0x00007f107d534120,                                         ),                                     ),                                     serializer: Nullable(                                         NullableSerializer {                                             serializer: Function(                                                 FunctionPlainSerializer {                                                     func: Py(                                                         0x00007f107a7edc60,                                                     ),                                                     name: "plain_function[_serialize_secret_field]",                                                     function_name: "_serialize_secret_field",                                                     return_serializer: Any(                                                         AnySerializer,                                                     ),                                                     fallback_serializer: None,                                                     when_used: Always,                                                     is_field_serializer: false,                                                     info_arg: true,                                                 },                                             ),                                         },                                     ),                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                     "expires_in": SerField {                         key_py: Py(                             0x00007f10799ff8b0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             Int(                                 IntSerializer,                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                     "access_token": SerField {                         key_py: Py(                             0x00007f10799ffcb0,                         ),                         alias: None,                         alias_py: None,                         serializer: Some(                             Function(                                 FunctionPlainSerializer {                                     func: Py(                                         0x00007f107a7edc60,                                     ),                                     name: "plain_function[_serialize_secret_field]",                                     function_name: "_serialize_secret_field",                                     return_serializer: Any(                                         AnySerializer,                                     ),                                     fallback_serializer: None,                                     when_used: Always,                                     is_field_serializer: false,                                     info_arg: true,                                 },                             ),                         ),                         required: true,                         serialize_by_alias: None,                         serialization_exclude_if: None,                     },                 },                 computed_fields: Some(                     ComputedFields(                         [],                     ),                 ),                 mode: SimpleDict,                 extra_serializer: None,                 filter: SchemaFilter {                     include: None,                     exclude: None,                 },                 required_fields: 3,             },         ),         has_extra: false,         root_model: false,         name: "Token",     }, ), definitions=[])

The pydantic-core SchemaSerializer used to dump instances of the model.

__pydantic_setattr_handlers__ = {}

__setattr__ handlers. Memoizing the handlers leads to a dramatic performance improvement in __setattr__

__pydantic_validator__ = SchemaValidator(title="Token", validator=Model(     ModelValidator {         revalidate: Never,         validator: ModelFields(             ModelFieldsValidator {                 fields: [                     Field {                         name: "expires_in",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "expires_in",                                         py_key: Py(                                             0x00007f1079600db0,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f10799ff8b0,                         ),                         validator: Int(                             IntValidator {                                 strict: false,                             },                         ),                         frozen: false,                     },                     Field {                         name: "access_token",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "access_token",                                         py_key: Py(                                             0x00007f1079603530,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f10799ffcb0,                         ),                         validator: LaxOrStrict(                             LaxOrStrictValidator {                                 strict: false,                                 lax_validator: JsonOrPython(                                     JsonOrPython {                                         json: FunctionAfter(                                             FunctionAfterValidator {                                                 validator: Str(                                                     StrValidator {                                                         strict: false,                                                         coerce_numbers_to_str: false,                                                     },                                                 ),                                                 func: Py(                                                     0x00005586fe456a10,                                                 ),                                                 config: Py(                                                     0x00007f1079600e00,                                                 ),                                                 name: "function-after[SecretStr(), str]",                                                 field_name: None,                                                 info_arg: false,                                             },                                         ),                                         python: Union(                                             UnionValidator {                                                 mode: Smart,                                                 choices: [                                                     (                                                         IsInstance(                                                             IsInstanceValidator {                                                                 class: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 class_repr: "SecretStr",                                                                 name: "is-instance[SecretStr]",                                                             },                                                         ),                                                         None,                                                     ),                                                     (                                                         FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: false,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079600e00,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         None,                                                     ),                                                 ],                                                 custom_error: Some(                                                     KnownError(                                                         PydanticKnownError {                                                             error_type: StringType {                                                                 context: None,                                                             },                                                         },                                                     ),                                                 ),                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                             },                                         ),                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                     },                                 ),                                 strict_validator: JsonOrPython(                                     JsonOrPython {                                         json: FunctionAfter(                                             FunctionAfterValidator {                                                 validator: Str(                                                     StrValidator {                                                         strict: true,                                                         coerce_numbers_to_str: false,                                                     },                                                 ),                                                 func: Py(                                                     0x00005586fe456a10,                                                 ),                                                 config: Py(                                                     0x00007f1079600e00,                                                 ),                                                 name: "function-after[SecretStr(), str]",                                                 field_name: None,                                                 info_arg: false,                                             },                                         ),                                         python: Union(                                             UnionValidator {                                                 mode: Smart,                                                 choices: [                                                     (                                                         IsInstance(                                                             IsInstanceValidator {                                                                 class: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 class_repr: "SecretStr",                                                                 name: "is-instance[SecretStr]",                                                             },                                                         ),                                                         None,                                                     ),                                                     (                                                         FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: true,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079600e00,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         None,                                                     ),                                                 ],                                                 custom_error: Some(                                                     KnownError(                                                         PydanticKnownError {                                                             error_type: StringType {                                                                 context: None,                                                             },                                                         },                                                     ),                                                 ),                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                             },                                         ),                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                     },                                 ),                                 name: "lax-or-strict[lax=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]],strict=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]]",                             },                         ),                         frozen: false,                     },                     Field {                         name: "refresh_token",                         lookup_key_collection: LookupKeyCollection {                             by_name: Simple(                                 LookupPath {                                     first_item: PathItemString {                                         key: "refresh_token",                                         py_key: Py(                                             0x00007f1079602670,                                         ),                                     },                                     rest: [],                                 },                             ),                             by_alias: None,                             by_alias_then_name: None,                         },                         name_py: Py(                             0x00007f10799ffdb0,                         ),                         validator: WithDefault(                             WithDefaultValidator {                                 default: Default(                                     Py(                                         0x00007f107d534120,                                     ),                                 ),                                 on_error: Raise,                                 validator: Nullable(                                     NullableValidator {                                         validator: LaxOrStrict(                                             LaxOrStrictValidator {                                                 strict: false,                                                 lax_validator: JsonOrPython(                                                     JsonOrPython {                                                         json: FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: false,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079600e00,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         python: Union(                                                             UnionValidator {                                                                 mode: Smart,                                                                 choices: [                                                                     (                                                                         IsInstance(                                                                             IsInstanceValidator {                                                                                 class: Py(                                                                                     0x00005586fe456a10,                                                                                 ),                                                                                 class_repr: "SecretStr",                                                                                 name: "is-instance[SecretStr]",                                                                             },                                                                         ),                                                                         None,                                                                     ),                                                                     (                                                                         FunctionAfter(                                                                             FunctionAfterValidator {                                                                                 validator: Str(                                                                                     StrValidator {                                                                                         strict: false,                                                                                         coerce_numbers_to_str: false,                                                                                     },                                                                                 ),                                                                                 func: Py(                                                                                     0x00005586fe456a10,                                                                                 ),                                                                                 config: Py(                                                                                     0x00007f1079600e00,                                                                                 ),                                                                                 name: "function-after[SecretStr(), str]",                                                                                 field_name: None,                                                                                 info_arg: false,                                                                             },                                                                         ),                                                                         None,                                                                     ),                                                                 ],                                                                 custom_error: Some(                                                                     KnownError(                                                                         PydanticKnownError {                                                                             error_type: StringType {                                                                                 context: None,                                                                             },                                                                         },                                                                     ),                                                                 ),                                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                                             },                                                         ),                                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                                     },                                                 ),                                                 strict_validator: JsonOrPython(                                                     JsonOrPython {                                                         json: FunctionAfter(                                                             FunctionAfterValidator {                                                                 validator: Str(                                                                     StrValidator {                                                                         strict: true,                                                                         coerce_numbers_to_str: false,                                                                     },                                                                 ),                                                                 func: Py(                                                                     0x00005586fe456a10,                                                                 ),                                                                 config: Py(                                                                     0x00007f1079600e00,                                                                 ),                                                                 name: "function-after[SecretStr(), str]",                                                                 field_name: None,                                                                 info_arg: false,                                                             },                                                         ),                                                         python: Union(                                                             UnionValidator {                                                                 mode: Smart,                                                                 choices: [                                                                     (                                                                         IsInstance(                                                                             IsInstanceValidator {                                                                                 class: Py(                                                                                     0x00005586fe456a10,                                                                                 ),                                                                                 class_repr: "SecretStr",                                                                                 name: "is-instance[SecretStr]",                                                                             },                                                                         ),                                                                         None,                                                                     ),                                                                     (                                                                         FunctionAfter(                                                                             FunctionAfterValidator {                                                                                 validator: Str(                                                                                     StrValidator {                                                                                         strict: true,                                                                                         coerce_numbers_to_str: false,                                                                                     },                                                                                 ),                                                                                 func: Py(                                                                                     0x00005586fe456a10,                                                                                 ),                                                                                 config: Py(                                                                                     0x00007f1079600e00,                                                                                 ),                                                                                 name: "function-after[SecretStr(), str]",                                                                                 field_name: None,                                                                                 info_arg: false,                                                                             },                                                                         ),                                                                         None,                                                                     ),                                                                 ],                                                                 custom_error: Some(                                                                     KnownError(                                                                         PydanticKnownError {                                                                             error_type: StringType {                                                                                 context: None,                                                                             },                                                                         },                                                                     ),                                                                 ),                                                                 name: "union[is-instance[SecretStr],function-after[SecretStr(), str]]",                                                             },                                                         ),                                                         name: "json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]",                                                     },                                                 ),                                                 name: "lax-or-strict[lax=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]],strict=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]]",                                             },                                         ),                                         name: "nullable[lax-or-strict[lax=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]],strict=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]]]",                                     },                                 ),                                 validate_default: false,                                 copy_default: false,                                 name: "default[nullable[lax-or-strict[lax=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]],strict=json-or-python[json=function-after[SecretStr(), str],python=union[is-instance[SecretStr],function-after[SecretStr(), str]]]]]]",                                 undefined: Py(                                     0x00007f107b128510,                                 ),                             },                         ),                         frozen: false,                     },                 ],                 model_name: "Token",                 extra_behavior: Ignore,                 extras_validator: None,                 extras_keys_validator: None,                 strict: false,                 from_attributes: false,                 loc_by_alias: true,                 validate_by_alias: None,                 validate_by_name: None,             },         ),         class: Py(             0x00005586febf51e0,         ),         generic_origin: None,         post_init: None,         frozen: false,         custom_init: false,         root_model: false,         undefined: Py(             0x00007f107b128510,         ),         name: "Token",     }, ), definitions=[], cache_strings=True)

The pydantic-core SchemaValidator used to validate instances of the model.

__signature__ = <Signature (*, expires_in: int, access_token: pydantic.types.SecretStr, refresh_token: pydantic.types.SecretStr | None = None) -> None>

The synthesized __init__ [Signature][inspect.Signature] of the model.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class blacksmith.middleware._async.oauth2_token.AsyncOAuth2RefreshTokenMiddlewareFactory(*, client_id: str | UUID, client_secret: SecretStr | None = None, refresh_token: SecretStr | None = None, token_url: str, transport: AsyncAbstractTransport, timeout: HTTPTimeout | None = None, middlewares: list[AsyncHTTPMiddleware] | None = None, token_drift_seconds: int = 30, raise_oauth2_error: bool = True)

A middleware based on OAuth2.0 using a refresh token.

Parameters:
  • client_id – OAuth2.0 client id.

  • client_secret – OAuth2.0 client secret.

  • refresh_token – OAuth2.0 refresh token.

  • token_url – OAUth2 authorization server token url.

  • transport – Blacksmith transport to use.

  • timeout – HTTP timeout for the authorization server to retrieve token.

  • middlewares – List of blacksmith middleware to the token http call.

  • token_drift_seconds – Seconds to add to the expires in to avoid consuming an expired access token.

client_id: str | UUID
client_secret: SecretStr | None
refresh_token: SecretStr | None
access_token: SecretStr | None
expires_at: datetime | None
bmclient: Any
get_client() AsyncClient[HTTPError]
async get_new_token() None
async get_access_token() SecretStr | None

Return an access token from the refresh_token

__call__(next: AsyncMiddleware) AsyncMiddleware

Call self as a function.