The authomatic.login() function needs access to functionality like getting the URL of the handler where it is being called, getting the request params and cookies and writing the body, headers and status to the response.

Since implementation of these features varies across Python web frameworks, the Authomatic library uses adapters to unify these differences into a single interface.

Available Adapters

If you are missing an adapter for the framework of your choice, please open an enhancement issue or consider a contribution to this module by implementing one by yourself. Its very easy and shouldn’t take you more than a few minutes.

class authomatic.adapters.DjangoAdapter(request, response)[source]

Adapter for the Django framework.

class authomatic.adapters.Webapp2Adapter(handler)[source]

Adapter for the Webapp2 framework.

Inherits from the WebObAdapter.

Parameters:handler – A webapp2.RequestHandler instance.
class authomatic.adapters.WebObAdapter(request, response)[source]

Adapter for the WebOb package.

  • request – A WebOb Request instance.
  • response – A WebOb Response instance.
class authomatic.adapters.WerkzeugAdapter(request, response)[source]

Adapter for Flask and other Werkzeug based frameworks.

Thanks to Mark Steve Samson.


Implementing an Adapter

Implementing an adapter for a Python web framework is pretty easy.

Do it by subclassing the BaseAdapter abstract class. There are only six members that you need to implement.

Moreover if your framework is based on the WebOb or Werkzeug package you can subclass the WebObAdapter or WerkzeugAdapter respectively.

class authomatic.adapters.BaseAdapter[source]

Base class for platform adapters

Defines common interface for WSGI framework specific functionality.


Must return a dict of all request parameters of any HTTP method.


Must return the url of the actual request including path but without query and fragment


Must return cookies as a dict.


Must write specified value to response.

Parameters:value (str) – String to be written to response.
set_header(key, value)[source]

Must set response headers to Key: value.

  • key (str) – Header name.
  • value (str) – Header value.

Must set the response status e.g. '302 Found'.

Parameters:status (str) – The HTTP response status.
Fork me on GitHub