Token Transport handlers
fastauth.transport.TRANSPORT_GETTER
module-attribute
TRANSPORT_GETTER = {'headers': BearerTransport, 'cookies': CookieTransport}
fastauth.transport.get_token_from_request
get_token_from_request(config, request=None, refresh=False, locations=None)
Get token from request using the token transport locations specified in the FastAuthConfig.TOKEN_LOCATIONS. If the token is not found in any of the locations, raise a MissingToken exception. Because used FastAPI SecuredBase, in Transport.scheme() method, we need to return callable to resolve the dependency later.
PARAMETER | DESCRIPTION |
---|---|
config
|
FastAuthConfig
TYPE:
|
request
|
FastAPI Request
TYPE:
|
refresh
|
flag to set refresh token type
TYPE:
|
locations
|
pass locations to get token from or default will be used
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Callable[..., Coroutine[Any, Any, str]]
|
Callable with coroutine to pass to FastAPI Depends |
Source code in fastauth/transport/__init__.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
fastauth.transport.get_login_response
async
get_login_response(security, tokens, response=None)
Get login response from the token locations specified in the FastAuthConfig.TOKEN_LOCATIONS.
PARAMETER | DESCRIPTION |
---|---|
security
|
FastAuth instance
TYPE:
|
tokens
|
TokenResponse instance with access and/or refresh tokens
TYPE:
|
response
|
Optional FastAPI Response to modify to
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
FastAPI Response with multiple token locations(eg. headers, cookies) set |
Source code in fastauth/transport/__init__.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
fastauth.transport.get_logout_response
async
get_logout_response(security, response=None)
Get logout response from the token locations specified in the FastAuthConfig.TOKEN_LOCATIONS.
PARAMETER | DESCRIPTION |
---|---|
security
|
FastAuth instance
TYPE:
|
response
|
Optional FastAPI Response to modify to
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
FastAPI Response with unset action for multiple token locations |
Source code in fastauth/transport/__init__.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|