Skip to main content

Sanic Api Key

Basic support for API Keys. Support form, args, header.

Installion

pip install sanicapikey

Example Usage

from sanic import Sanic
from sanic.response import text, json
from SanicApiKey import SanicApiKey

app = Sanic('test')

async def test(request):
    return json({ "error": 'invalid api key' })

auth = SanicApiKey(app, 'api_key', keys=['hello', 'world'], error=test)

# Header:
# auth = SanicApiKey(app, header='api_key', keys=['hello', 'world'], error=test)

# Form
# auth = SanicApiKey(app, form='api_key', keys=['hello', 'world'], error=test)

@app.route('/')
@auth.key_required
async def test(request):
    return json({'success': True, 'key': auth.get_token()})

if __name__ == '__main__':
    app.run(host='localhost', port=8000)

Metadata

Release files for SanicApiKey 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for SanicApiKey 1.0.1
File Size Uploaded
SanicApiKey-1.0.1.tar.gz 2.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for SanicApiKey 1.0.1
File Interpreter ABI Platform
SanicApiKey-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 4.8 kB

Release files / SanicApiKey-1.0.1.tar.gz

Download URL SanicApiKey-1.0.1.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f5dd42c5dbb9fc538812dae1f5c1d689a54df31829987f5e603e676df457f71c
BLAKE2b-256 checksum
How to use checksums
0a87db50850b972ef83884d4d9b12176577c1322dde53d250b096a3102d2f58d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5

Release files / SanicApiKey-1.0.1-py3-none-any.whl

Download URL SanicApiKey-1.0.1-py3-none-any.whl
Size 2.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bae9893892763381d1c73ae9ead3ad2135b4134cdd577cb799d402c7459e21e3
BLAKE2b-256 checksum
How to use checksums
d9172560f86822d244bc5a056b107f2076b77fc2817f6f63358a8b831cccfe87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page