@@ -102,25 +102,22 @@ def authorize(self, login, password, scopes=None, note='', note_url='',
102
102
"""
103
103
json = None
104
104
# TODO: Break this behaviour in 1.0 (Don't rely on self._session.auth)
105
- auth = self ._session .auth or (login and password )
105
+ auth = None
106
+ if self ._session .auth :
107
+ auth = self ._session .auth
108
+ elif login and password :
109
+ auth = (login ,password )
110
+
106
111
if auth :
107
112
url = self ._build_url ('authorizations' )
108
113
data = {'note' :note ,'note_url' :note_url ,
109
114
'client_id' :client_id ,'client_secret' :client_secret }
110
115
if scopes :
111
116
data ['scopes' ]= scopes
112
- # TODO: Unconditionally use the login and password, e.g.,
113
- # old_auth = self._session.auth
114
- # self.login(login, password)
115
- # json = self._json(...)
116
- # self._session.auth = old_auth
117
- do_logout = False
118
- if not self ._session .auth :
119
- do_logout = True
120
- self .login (login ,password )
121
- json = self ._json (self ._post (url ,data = data ),201 )
122
- if do_logout :
123
- self ._session .auth = None
117
+
118
+ with self ._session .temporary_basic_auth (* auth ):
119
+ json = self ._json (self ._post (url ,data = data ),201 )
120
+
124
121
return Authorization (json ,self )if json else None
125
122
126
123
def check_authorization (self ,access_token ):