oauth2.web — Interaction over HTTP

Classes for handling a HTTP request/response flow.

class oauth2.web.SiteAdapter[source]

Interact with a user.

Display HTML or redirect the user agent to another page of your website where she can do something before being returned to the OAuth 2.0 server.

SiteAdapter.authenticate(request, environ, scopes)[source]

Authenticates a user and checks if she has authorized access.

  • request – An instance of oauth2.web.Request.
  • environ – Environment variables of the request.
  • scopes – A list of strings with each string being one requested scope.

A dict containing arbitrary data that will be passed to the current storage adapter and saved with auth code and access token.


oauth2.error.UserNotAuthenticated if the user could not be authenticated.

SiteAdapter.render_auth_page(request, response, environ)[source]

Defines how to display a confirmation page to the user.


The response passed in as a parameter. It can contain HTML or issue a redirect.


Checks if the user has denied access. This will lead to python-oauth2 returning a “acess_denied” response to the requesting client app.

Parameters:request – An instance of oauth2.web.Request.
Returns:Return True if the user has denied access.
class oauth2.web.Request(env)[source]

Contains data of the current HTTP request.

Request.get_param(name, default=None)[source]

Returns a param of a GET request identified by its name.

Request.post_param(name, default=None)[source]

Returns a param of a POST request identified by its name.

class oauth2.web.Response[source]

Contains data returned to the requesting user agent.