Skip to content

Instantly share code, notes, and snippets.

@alces
Created May 30, 2017 06:41
Show Gist options
  • Save alces/f22c24001b2666fb687d19ee6810173d to your computer and use it in GitHub Desktop.
Save alces/f22c24001b2666fb687d19ee6810173d to your computer and use it in GitHub Desktop.
Eve server with token authentication
#!/usr/bin/env python
# to connect it using curl:
# curl -H 'Authorization: Token 9d003d9a-2288-46b8-bfeb-7cec1eb53074' http://my.host.name/api/my_collection/
import eve
class MyTokenAuth(eve.auth.TokenAuth):
def check_auth(self, token, allowed_roles, resource, method):
return token == '9d003d9a-2288-46b8-bfeb-7cec1eb53074'
app = eve.Eve(auth = MyTokenAuth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment