Soundcloud python OAuth error
Question: This should be a fairly simple Python app which uses OAuth to authenticate
itself with the soundclodu API. It follows very closely the code for the
official library: <https://github.com/soundcloud/soundcloud-python>

When I load my app, I get sent to the soundcloud login page, which then re-
directs me to /user with the code query string.

However, it fails at the part where I attempt to obtain the access
token,etc...

This is the error I get:

    
    
     File "/Users/asselinpaul/Dropbox/UPENN/SPRING15/CIS192/final_project/server.py", line 19, in user
                code = request.args.get('code'))
     TypeError: 'Resource' object is not iterable    
    

I'm pretty sure this just means that client.exchange_token is returning a 401
error (this is what happens when I try to print client.exchange_token(code =
request.args.get('code')).

Code:

    
    
        import soundcloud
        from 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)
    


Answer: I have a similar application (exactly the same, basically) and when I run it I
get an error that says:

    
    
    AttributeError: 'module' object has no attribute 'args'
    

As far as I can tell, because request.py in the soundcloud module uses urllib
this is probably an issue with python 2.x versus python 3.x. I am using python
3 which I don't think can use urllib. I'd love to have a better answer or a
real solution, but this is just what I've gathered.

