JWTdown for React#
JWTdown for React is a JavaScript module that provides React hooks and other tools that facilitate development of front ends that use JWTdown-Fastapi as a back-end authentication provider.
Quick start#
Adding authentication to your application has never been so
easy with JWTdown. The goal of JWTdown-for-react
is to
enable authentication with the least amount of burden while
providing the security of JWTdown-FastAPI
.
Note
You must deploy
JWTdown-FastAPI
on your backend so JWTdown-for-React
has a service to
retrieve a token from.
By default, JWTdown-FastAPI
provides the following
endpoints for a minimal implementation of authorization:
METHOD
PATH
Description
GET
/token
Retrieves token and account data.
Response
{
"access_token": "string",
"token_type": "Bearer",
"account": {
// ...other user data...
"username": "string",
"id": 0,
"hashed_password": "string"
}
}
DELETE
/token
End current user session.
Response
true
POST
/token
Login to JWTdown-FastAPI authorization service.
Request
const formData = new FormData();
const username = "string";
const password = "string";
formData.append("username", username);
formData.append("password", password);
Response
{
"access_token": "string",
"token_type": "Bearer"
}
Installation and customization#
Navigate to an NPM project root directory. You should have a file called
package.json
in the path.Run the following command to install this package as a dependency of your project.
npm install @galvanize-inc/jwtdown-for-react