semvec/pypi-packages huggingface dataset:
fastapi-simple-bearer 0.1.2
The simpliest way to secure your API with preset token
Requires Python: <4.0,>=3.10

# FastAPI Simple Bearer (FSB)
This library provides you with ability to secure your endpoints with preset token (or tokens) in the "Authorization: Bearer" header

> [!CAUTION]
> There are negative potential consequences of using a hard coded token.
>
> You may want to use JWT tokens: 
> https://github.com/sijokun/async-fastapi-jwt-auth

## Installation

The easiest way to start working with this library is to install it from pip

`pip install fastapi-simple-bearer`

## Example of usage
Basic usage:
```python
from fastapi import Depends, FastAPI
from fastapi_simple_bearer import FSB, FSBToken

app = FastAPI()

fsb = FSB(token="SUPER_SECRET_TOKEN")

@app.get("/secure")
async def secure(auth: FSBToken = Depends(fsb)):
    return {"token": auth.token}

```
Other examples are available in [examples](examples) folder