dmitry-viskov / pylti1.3-flask-example

PyLTI1p3 Flask usage example
MIT License
19 stars 29 forks source link

Incorrect get_jwks resulting in `no implicit conversion of String into Integer` #17

Open petervtzand opened 1 year ago

petervtzand commented 1 year ago

In https://github.com/dmitry-viskov/pylti1.3-flask-example/blob/master/game/app.py#L128 you do

return jsonify({'keys': tool_conf.get_jwks()})

but tool_conf.get_jwks() already returns something like {'keys': <the keys>} (see https://github.com/dmitry-viskov/pylti1.3/blob/master/pylti1p3/tool_config/abstract.py#L117) so this route results into something like

  "keys": {
    "keys": [ ... ] 
  }

So what you should do is just

return jsonify(tool_conf.get_jwks())

For me this resulted in 500 errors while testing deep_linking and names & roles services:

Screenshot 2022-12-30 at 13 57 38
Chengze-Wu commented 8 months ago

I modified the code to: Please try if it works for you.

@app.route('/jwks/', methods=['GET'])
def get_jwks():
    tool_conf = ToolConfJsonFile(get_lti_config_path())
    # return jsonify({'keys': tool_conf.get_jwks()})
    format_json_str = json.dumps(tool_conf.get_jwks(), separators=(',',':'))
    return format_json_str