Models

Module Reference

OAuth 2.0 Django Models

class oauth2app.models.AccessRange(*args, **kwargs)[source]

Stores access range data, also known as scope.

Args:

  • key: A string representing the access range scope. Used in access token requests.

Kwargs:

  • description: A string representing the access range description. Default None
exception DoesNotExist
exception AccessRange.MultipleObjectsReturned
AccessRange.accesstoken_set
AccessRange.code_set
AccessRange.objects = <django.db.models.manager.Manager object>
class oauth2app.models.AccessToken(*args, **kwargs)[source]

Stores access token data.

Args:

  • client: A oauth2app.models.Client object
  • user: A Django User object

Kwargs:

  • token: A string representing the access key token. Default 10 character random string
  • refresh_token: A string representing the access key token. Default 10 character random string
  • mac_key: A string representing the MAC key. Default None
  • expire: A positive integer timestamp representing the access token’s expiration time.
  • scope: A list of oauth2app.models.AccessRange objects. Default None
  • refreshable: A boolean that indicates whether this access token is refreshable. Default False
exception DoesNotExist
exception AccessToken.MultipleObjectsReturned
AccessToken.client
AccessToken.macnonce_set
AccessToken.objects = <django.db.models.manager.Manager object>
AccessToken.scope
AccessToken.user
class oauth2app.models.Client(*args, **kwargs)[source]

Stores client authentication data.

Args:

  • name: A string representing the client name.

  • user: A Django User object representing the client

    owner.

Kwargs:

  • description: A string representing the client description. Default None
  • key: A string representing the client key. Default 30 character random string
  • secret: A string representing the client secret. Default 30 character random string
  • redirect_uri: A string representing the client redirect_uri. Default None
exception DoesNotExist
exception Client.MultipleObjectsReturned
Client.accesstoken_set
Client.code_set
Client.objects = <django.db.models.manager.Manager object>
Client.user
class oauth2app.models.Code(*args, **kwargs)[source]

Stores authorization code data.

Args:

  • client: A oauth2app.models.Client object
  • user: A Django User object

Kwargs:

  • key: A string representing the authorization code. Default 30 character random string
  • expire: A positive integer timestamp representing the access token’s expiration time.
  • redirect_uri: A string representing the redirect_uri provided by the requesting client when the code was issued. Default None
  • scope: A list of oauth2app.models.AccessRange objects. Default None
exception DoesNotExist
exception Code.MultipleObjectsReturned
Code.client
Code.objects = <django.db.models.manager.Manager object>
Code.scope
Code.user
class oauth2app.models.KeyGenerator(length)[source]

Callable Key Generator that returns a random keystring.

Args:

  • length: A integer indicating how long the key should be.

Returns str

class oauth2app.models.MACNonce(*args, **kwargs)[source]

Stores Nonce strings for use with MAC Authentication.

Args:

  • access_token: A oauth2app.models.AccessToken object
  • nonce: A unique nonce string.
exception DoesNotExist
exception MACNonce.MultipleObjectsReturned
MACNonce.access_token
MACNonce.objects = <django.db.models.manager.Manager object>
class oauth2app.models.TimestampGenerator(seconds=0)[source]

Callable Timestamp Generator that returns a UNIX time integer.

Kwargs:

  • seconds: A integer indicating how many seconds in the future the timestamp should be. Default 0

Returns int