Skip to content
This repository has been archived by the owner on Oct 3, 2019. It is now read-only.

managedbyq/mbq.tokens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mbq.tokens: fool-proof token decoding

Installation

$ pip install mbq.tokens
🚀✨

Guaranteed fresh.

Getting started

from mbq import tokens

tokens.init(
    certificate=settings.FORMATTED_CERTIFICATE,
    allowed_audiences=set(settings.ALLOWED_AUDIENCES),
)

try:
    decoded_token = tokens.decode(token)
except tokens.TokenError:
    # will only ever raise TokenError
    logger.exception('Failed to decode token')

decoded_token = tokens.decode_header(request.META['HTTP_AUTHORIZATION'])