class Token(models.Model):
REQUEST = 1
ACCESS = 2
- TOKEN_TYPES = ((REQUEST, 'Request'), (ACCESS, 'Access'))
+ REFRESH = 3
+ TOKEN_TYPES = (
+ (REQUEST, 'Request'),
+ (ACCESS, 'Access'),
+ (REFRESH, 'Refresh')
+ )
key = models.CharField(max_length=KEY_SIZE)
secret = models.CharField(max_length=SECRET_SIZE)
settings.AUTH_USER_MODEL, models.CASCADE,
null=True, blank=True, related_name='tokens'
)
- consumer = models.ForeignKey(Consumer, models.CASCADE)
+ consumer = models.ForeignKey(Consumer, models.CASCADE, null=True, blank=True)
def __str__(self):
return "%s Token %s for %s" % (self.get_token_type_display(), self.key, self.consumer)