liluo / py-oauth2 Goto Github PK
View Code? Open in Web Editor NEWA Python wrapper for the OAuth 2.0 specification
Home Page: http://liluo.org/py-oauth2/
A Python wrapper for the OAuth 2.0 specification
Home Page: http://liluo.org/py-oauth2/
Hi there, it's me again.
Since the last time I asked about download large file streamly via OAuth2
, I eventually found there's possibly a bug in your code. I noticed an unnormal RAM usage which would even use up all RAM on old computers. This happens during the last few seconds of downloading a file (50+ MB).
And I found this is somethins related to this line:
py-oauth2/pyoauth2/libs/response.py
Line 29 in 313f195
If changed to:
options = {'parse': 'text'}
options.update(opts)
if options['parse'] in ('text', 'query', 'json', ):
self.body = response.text
would solve this problem, and also lower the RAM usage during small size file downloading.
https://github.com/liluo/py-oauth2/blob/master/pyoauth2/client.py#L39
里面处理了 response,但是没有保留这个 response 对象,导致外层无法获取 response.body 对象,有时候服务器报了异常,比如 code error / invalid user id,就没法判断哪里出问题了,
我建议将这个 response 保存到 self.response。
Hi. I was using this little tool for OAuth 2 authentication, and I recently found something confusing.
Think about downloading a large file via OAuth 2. 'Cause the file is very large, I don't want the client to read it all into memory at once. Instead, I thought I could use the iter_content()
method of requests.models.Response
to write the file to disk block by block, since your tool uses requests
. Yet I've read your code, and did not see the stream
parameter being passed to the client.request()
method, and I think this might be a bug.
As far as I know, requests
does require this parameter to be passed to Request
to work as the way I described above.
Could you please explain some of your code? If this is rather a feature or something designed than a bug, I'd be glad to hear from you about the right way to do my work.
和
https://github.com/simplegeo/python-oauth2
的包名冲突了,改个名吧。
client = Client(CLIENT_ID, CLIENT_SECRET,
site='https://www.googleapis.com/oauth2/v1',
authorize_url='https://accounts.google.com/o/oauth2/auth',
token_url='https://accounts.google.com/o/oauth2/token')
print '-' * 80
authorize_url = client.auth_code.authorize_url(redirect_uri=REDIRECT_URL,
scope=SCOPE)
app = Flask(__name__)
@app.route("/")
def hello():
print "hello world"
return redirect(authorize_url)
@app.route("/oauth2callback")
def oauth2callback():
How do i get access to user info in oauth2callback in this example?
I got the error as:
TypeError: exceptions must derive from BaseException
for the line of:
pyoauth2/libs/access_token.py", line 39, in refresh
in python 3.4. I have not test on 3.3 yet.
When access_token
returns in format 'query', then the access_token.expires_in
is str
, not a int
.
This situation caused access_token.expires_at
is not set.
see https://github.com/liluo/py-oauth2/blob/master/oauth2/libs/access_token.py#L13
首先感谢作者提供了这么简洁的工具。已经在使用了,总体感觉很好用,但是用的时候还是发现了两处bug。
第一个地方是在libs/access_token.py 82行左右,原文是:
opts['body'][self.opts['param_name']] = token
我想作者的原意应该是:
opts['body'][self.opts['param_name']] = self.token
第二个地方是在libs/request.py ,因为url参数和配置项都是通过 **opt 传递,但是如果接口参数和配置项重名的话就报错了,我觉得应该有一个params的配置项,这个配置项传递url的参数。奇怪的是我在libs/access_token.py 的__set_token 这个函数中看到了params配置项,但是在libs/request.py中没有看到对其进行处理。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.