I am creating a web based application and want to get data from Basecamp using their API through OAuth2. I have successfully redirected my page to this link my redirect_uri, but I couldnt get any access token from the page.
How to get the access token using the flask application that I have created? Any code samples will be much appreciated.
@app.route('/')
def index():
if 'basecamp_token' in session:
ret = remote.get('email')
return jsonify(ret.data)
return redirect(url_for('login'))
else:
return redirect(url_for('redirecturl'))
@app.route('/login')
def login():
return basecamp.authorize(callback=url_for('authorized', next=request.args.get('next') or request.referrer or None))
@app.route('/authorized')
@basecamp.authorized_handler
def authorized(resp):
if resp is None:
return 'Access denied: error=%s' % (
request.args['error']
)
if 'basecamp_token' in resp:
# session['example_oauth'] = resp
print(resp)
return jsonify(resp)
return str(resp)
@app.route("/redirecturl")
def redirecturl():
return redirect('http://basecamp.com/oauth2')
if __name__ == '__main__':
app.secret_key = 'super_secret'
app.run(port=8000, debug=True)