Skip to content

Instantly share code, notes, and snippets.

@newsomc
Created January 4, 2014 13:16
Show Gist options
  • Save newsomc/8255232 to your computer and use it in GitHub Desktop.
Save newsomc/8255232 to your computer and use it in GitHub Desktop.
from requests_oauthlib import OAuth1Session
from flask import Flask, request
from flask.json import jsonify
import os
app = Flask(__name__)
# Get the access token from the environment variables
api_key = os.environ.get('BEATPORT_API_KEY', None)
api_key_secret = os.environ.get('BEATPORT_API_KEY_SECRET', None)
access_token = os.environ.get('BEATPORT_API_ACCESS_TOKEN', None)
access_token_secret = os.environ.get('BEATPORT_API_ACCESS_TOKEN_SECRET', None)
def oauth_session():
"""
Configure an OAuth1Session object with access to the API.
"""
return OAuth1Session(
client_key=api_key,
client_secret=api_key_secret,
resource_owner_key=access_token,
resource_owner_secret=access_token_secret
)
@app.route("/")
def root():
request = oauth_session().get('https://oauth-api.beatport.com/catalog/3/beatport/home').json()
return jsonify(request)
if __name__ == '__main__':
app.secret_key = os.urandom(24)
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment