Auth fixes

This commit is contained in:
nikolark committed 2014-01-26 19:01:47 +01:00
1 parent 515008488f
commit 86bbb63c4f
3 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -34,9 +34,9 @@ class DuskenApi(object):
logging.error("Could not authenticate with API. Correct client_id, client_secret, username and password?\n{0}".format(e))
return None
return self.access_token
return self.oauth2_access_token
def get_access_token(self, username, password, scope='read', grant_type='password'):
def get_access_token(self, username, password, scope='read'):
resp = requests.post(
"{0}/oauth2/access_token/".format(self.base_url),
data=dict(
@@ -45,7 +45,7 @@ class DuskenApi(object):
client_id = self._client_id,
client_secret = self._client_secret,
scope=scope,
grant_type=grant_type))
grant_type='password'))
resp.raise_for_status()
-2
View File
@@ -72,9 +72,7 @@ class DuskenBackend(object):
return None
user = self._get_or_create_local_user(username)
self._refresh_access_token(user, access_token)
self._sync_user_detail(user)
return user
+2
View File
@@ -7,6 +7,8 @@ class DuskenAccessToken(models.Model):
expires_in = models.IntegerField()
scope = models.CharField(max_length=255)
user = models.OneToOneField(User)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
def __unicode__(self):
return u"{0} {1}".format(self.user, self.access_token)