Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46b0dac

Browse files
committed
Use new context manager
1 parentfe84d77 commit46b0dac

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

‎github3/github.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,22 @@ def authorize(self, login, password, scopes=None, note='', note_url='',
102102
"""
103103
json=None
104104
# TODO: Break this behaviour in 1.0 (Don't rely on self._session.auth)
105-
auth=self._session.author (loginandpassword)
105+
auth=None
106+
ifself._session.auth:
107+
auth=self._session.auth
108+
elifloginandpassword:
109+
auth= (login,password)
110+
106111
ifauth:
107112
url=self._build_url('authorizations')
108113
data= {'note':note,'note_url':note_url,
109114
'client_id':client_id,'client_secret':client_secret}
110115
ifscopes:
111116
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-
ifnotself._session.auth:
119-
do_logout=True
120-
self.login(login,password)
121-
json=self._json(self._post(url,data=data),201)
122-
ifdo_logout:
123-
self._session.auth=None
117+
118+
withself._session.temporary_basic_auth(*auth):
119+
json=self._json(self._post(url,data=data),201)
120+
124121
returnAuthorization(json,self)ifjsonelseNone
125122

126123
defcheck_authorization(self,access_token):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp