Last active
October 16, 2018 13:34
-
-
Save willgdjones/4df43fe8978e6868b92e523b9a0b9c71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/geneplaza/login', methods=['GET', 'POST']) | |
@login_required | |
def geneplaza_login(): | |
scopes = app.config['DEFAULT_SCOPES'] | |
redirect_uri = app.BASE_CLIENT_URL + 'geneplaza/auth' | |
client_id = app.config['GENEPLAZA_CLIENT_ID'] | |
submit_url = f"https://www.geneplaza.com/api/auth?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}&scope=dataset" | |
return redirect(submit_url) | |
@app.route('/geneplaza/auth', methods=['GET']) | |
@login_required | |
def geneplaza_auth(): | |
username = current_user.get_id() | |
auth_code = request.args.get("authorization_code") | |
dataset_id = request.args.get("dataset") | |
redirect_uri = app.BASE_CLIENT_URL + 'geneplaza/auth' | |
data = { | |
"data": { | |
"type": "token", | |
"attributes": { | |
"grant_type": "authorization_code", | |
"scope": dataset_id, | |
"code": auth_code, | |
"redirect_uri": redirect_uri | |
} | |
} | |
} | |
from requests.auth import HTTPBasicAuth | |
r = requests.post( | |
'https://developer.geneplaza.com/token', | |
auth=HTTPBasicAuth( | |
app.config['GENEPLAZA_CLIENT_ID'], | |
app.config['GENEPLAZA_CLIENT_SECRET'] | |
), | |
json=data | |
) |
Ok makes sense, thanks! Will try that now.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@willgdjones
This is my bad in the data
scope
should be a string"dataset"
You need the dataset id after to access it because the id should in the path
https://developer.geneplaza.com/datasets/<DATASET_ID>/files