Python 2.6
This commit is contained in:
1 parent
a91d1c94d3
commit
69ce83590f
3 files changed
+4
-4
No files matched your search
@@ -31,14 +31,14 @@ class DuskenApi(object):
|
||||
self.oauth2_access_token = self.get_access_token(username, password, scope='write')
|
||||
self.access_token = self.oauth2_access_token['access_token']
|
||||
except requests.exceptions.HTTPError as e:
|
||||
logging.error("Could not authenticate with API. Correct client_id, client_secret, username and password?\n{}".format(e))
|
||||
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
|
||||
|
||||
def get_access_token(self, username, password, scope='read', grant_type='password'):
|
||||
resp = requests.post(
|
||||
"{}/oauth2/access_token/".format(self.base_url),
|
||||
"{0}/oauth2/access_token/".format(self.base_url),
|
||||
data=dict(
|
||||
username=username,
|
||||
password=password,
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class Members(object):
|
||||
|
||||
def __request_auth_headers(self):
|
||||
return {
|
||||
'Authorization': "Oauth {}".format(self._api.access_token)
|
||||
'Authorization': "Oauth {0}".format(self._api.access_token)
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -6,4 +6,4 @@ class DuskenAccessToken(models.Model):
|
||||
user = models.OneToOneField(User)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"{} {}".format(self.user, self.access_token)
|
||||
return u"{0} {1}".format(self.user, self.access_token)
|
||||
Reference in new issue
Block a user