Bearer¶
With this transport, the token is expected inside the Authorization
header of the HTTP request with the Bearer
scheme. It's particularly suited for pure API interaction or mobile apps.
Configuration¶
from fastapi_users.authentication import BearerTransport
bearer_transport = BearerTransport(tokenUrl="auth/jwt/login")
As you can see, instantiation is quite simple. It accepts the following arguments:
tokenUrl
(str
): The exact path of your login endpoint. It'll allow the interactive documentation to automatically discover it and get a working Authorize button. In most cases, you'll probably need a relative path, not absolute. You can read more details about this in the FastAPI documentation.
Login¶
This method will return the in the following form upon successful login:
200 OK
Check documentation about login route.
Logout¶
The logout method with this transport returns nothing.
Authentication¶
This method expects that you provide a Bearer
authentication with a valid token corresponding to your strategy.