Soundcloud python OAuth error -
this should simple python app uses oauth authenticate soundclodu api. follows closely code official library: https://github.com/soundcloud/soundcloud-python
when load app, sent soundcloud login page, re-directs me /user code query string.
however, fails @ part attempt obtain access token,etc...
this error get:
file "/users/asselinpaul/dropbox/upenn/spring15/cis192/final_project/server.py", line 19, in user code = request.args.get('code')) typeerror: 'resource' object not iterable
i'm pretty sure means client.exchange_token returning 401 error (this happens when try print client.exchange_token(code = request.args.get('code')).
code:
import soundcloud flask import flask, redirect, request app = flask(__name__) client = soundcloud.client( client_id="*****************************", client_secret="*****************************", redirect_uri='http://127.0.0.1:5000/user' ) @app.route('/') def hello_world(): return redirect(client.authorize_url()) @app.route('/user') def user(): access_token, expires, scope, refresh_token = client.exchange_token( code = request.args.get('code')) return ("hi there, %s" % client.get('/me').username) if __name__ == '__main__': app.run(debug=true)
i have similar application (exactly same, basically) , when run error says:
attributeerror: 'module' object has no attribute 'args'
as far can tell, because request.py in soundcloud module uses urllib issue python 2.x versus python 3.x. using python 3 don't think can use urllib. i'd love have better answer or real solution, i've gathered.
Comments
Post a Comment