Skip to content

Instantly share code, notes, and snippets.

@willgdjones
Last active October 16, 2018 13:34
Show Gist options
  • Save willgdjones/4df43fe8978e6868b92e523b9a0b9c71 to your computer and use it in GitHub Desktop.
Save willgdjones/4df43fe8978e6868b92e523b9a0b9c71 to your computer and use it in GitHub Desktop.
@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
)
@willgdjones
Copy link
Author

Getting closer, now the error is:

{'errors': [{'title': 'The scope requested is invalid for this request', 'status': 400, 'meta': []}]}

@willgdjones
Copy link
Author

screen shot 2018-10-15 at 17 33 10

This is how the integration currently looks.

@rduque1
Copy link

rduque1 commented Oct 16, 2018

@willgdjones
This is my bad in the data scope should be a string "dataset"

data = {
  "data": {
         "type": "token",
         "attributes": {
         	"grant_type": "authorization_code",
         	"scope": "dataset"
                 "code": auth_code,
		"redirect_uri": redirect_uri
         }
    }
}

You need the dataset id after to access it because the id should in the path https://developer.geneplaza.com/datasets/<DATASET_ID>/files

@willgdjones
Copy link
Author

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