Skip to main content

Basic Sanic API Key plugin.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SanicApiKey-1.0.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

SanicApiKey-1.0.1-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file SanicApiKey-1.0.1.tar.gz.

File metadata

  • Download URL: SanicApiKey-1.0.1.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for SanicApiKey-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f5dd42c5dbb9fc538812dae1f5c1d689a54df31829987f5e603e676df457f71c
MD5 9c0149ffd3cc033c15168c38236213a9
BLAKE2b-256 0a87db50850b972ef83884d4d9b12176577c1322dde53d250b096a3102d2f58d

See more details on using hashes here.

File details

Details for the file SanicApiKey-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: SanicApiKey-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for SanicApiKey-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bae9893892763381d1c73ae9ead3ad2135b4134cdd577cb799d402c7459e21e3
MD5 9748a655568b91797d087b913727ad29
BLAKE2b-256 d9172560f86822d244bc5a056b107f2076b77fc2817f6f63358a8b831cccfe87

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page