Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Retrieving Cached Data in Flask App using ExtendedFlaskMessageLaunch #24

Open
arush3 opened this issue Dec 14, 2023 · 2 comments

Comments

@arush3
Copy link

arush3 commented Dec 14, 2023

I'm working on a Flask application using the pylti1.3-flask-example as a starting point and encountering an issue with retrieving cached data using ExtendedFlaskMessageLaunch.from_cache. The LMS I'm using is Moodle Cloud.

Relevant part of the code where the issue occurs

message_launch = ExtendedFlaskMessageLaunch.from_cache(launch_id, flask_request, tool_conf, launch_data_storage=launch_data_storage)

Here is the error I get in my Server log:
2023-12-14 02:31:58,043: pylti1p3.exception.LtiException: Launch data not found

This line is contained in the /configure/<launch_id>/< difficulty >/ endpoint.

Cache Storage does seem to be empty and message_launch cannot be retrieved by any of the endpoints after /launch where it is generated.

Please let me know if you are aware of a solution to this caching issue. Has anyone experienced a similar problem, or could someone provide insights into what might be going wrong?

Thank you in advance!

@eharvey71
Copy link

I can't quite recall but there was a reason I was avoiding ExtendedFlaskMessageLaunch. In my app, I'm using FlaskMessageLaunch only... Example:

@app.route('/launch/', methods=['POST'])
def launch():
    tool_conf = ToolConfJsonFile(get_lti_config_path())
    request = FlaskRequest()
    launch_data_storage = get_launch_data_storage()
    message_launch = FlaskMessageLaunch(
        request,
        tool_conf,
        launch_data_storage=launch_data_storage
    )
    message_launch_data = message_launch.get_launch_data()

@arush3
Copy link
Author

arush3 commented Dec 16, 2023

Thanks eharvey71.

I'm still getting a "Launch data not found" error inside the /api/scoreboard/ endpoint:
2023-12-16 15:28:22,937: File "/home/arush3/mysite_example/game/app_example.py", line 237, in scoreboard
2023-12-16 15:28:22,937: message_launch = FlaskMessageLaunch.from_cache(launch_id, flask_request, tool_conf,
2023-12-16 15:28:22,937:
2023-12-16 15:28:22,938: File "/home/arush3/.local/lib/python3.10/site-packages/pylti1p3/message_launch.py", line 297, in from_cache
2023-12-16 15:28:22,938: raise LtiException("Launch data not found")

I now also get "Invalid Nonce" errors most of the time, but after a few refreshes, the app loads without an "Invalid Nonce" error.

2023-12-16 15:24:36,732: File "/home/arush3/.local/lib/python3.10/site-packages/pylti1p3/message_launch.py", line 670, in validate_nonce
2023-12-16 15:24:36,732: raise LtiException("Invalid Nonce")

Please let me know if you've seen a similar issue or are aware of a solution.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants