GithubThe FastApi starter kit leverages the oneloop-python SDK under the hood, but provides a helpful middleware that can be used for verifying API keys.You can fork the starter kit repo, or copy the middleware from it.
You can also check for permissions in your routes. Let’s say you have a route that requires a specific read access for profile data.
You want to check if the API key has the required scope before returning the data. You can pass that scope to the middleware.Let’s modify the above route to check for profile read access.
routes.py
Copy
# Define your routes and check for permissions@app.get("/", dependencies=[Depends(oneloop_middleware([{"id": "profile", "read": True}]))])async def read_root(): return {"Hello": "World"}