FastbaseDependency
Source code in fastbase/main.py
Attributes
User: Type[USER]
instance-attribute
engine: AsyncEngine
instance-attribute
Functions
current_user(email)
async
Dependency for getting the user by their verified idtoken.
Use with
Use with the verify_idtoken
dependency which gets the User based on the email.
PARAMETER | DESCRIPTION |
---|---|
email |
Email taken from the bearer token
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Type[USER]
|
Valid user |
RAISES | DESCRIPTION |
---|---|
UserNotFoundError
|
The user who owns the email doesn't exist |
Source code in fastbase/main.py
verify_idtoken(authorization)
staticmethod
Dependency to verify if a Google idtoken is valid. Out of the decrypted data only the email is returned.
Use with
Use with the current_user
dependency which gets the User based on the email.
Example
PARAMETER | DESCRIPTION |
---|---|
authorization |
Bearer token taken taken from Google idtoken
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
str
|
Decrypted token data |
RAISES | DESCRIPTION |
---|---|
InvalidToken
|
Token cannot be used e.g. it's expired, malformed, etc. |