/pylti1.3-django-example

PyLTI1p3 Django usage example

Primary LanguagePythonMIT LicenseMIT

Example of usage PyLTI1p3 library within Django framework

PyLTI1p3 is a Python implementation of LTI 1.3 Advantage Tool.

First of all choose and configure test LTI 1.3 Platform. It may be:

The most simple way to check example is to use docker + docker-compose. Change the necessary configs in the configs/game.json (here is instruction how to generate your own public + private keys):

{
    "<issuer>" : [{ // This will usually look something like 'http://example.com'
        "default": true, // this block will be used in case if client-id was not passed
        "client_id" : "<client_id1>", // This is the id received in the 'aud' during a launch
        "auth_login_url" : "<auth_login_url>", // The platform's OIDC login endpoint
        "auth_token_url" : "<auth_token_url>", // The platform's service authorization endpoint
        "auth_audience": null, // The platform's OAuth2 Audience (aud). Is used to get platform's access token,
                               // Usually the same as "auth_token_url" but in the common case could be a different url
        "key_set_url" : "<key_set_url>", // The platform's JWKS endpoint
        "key_set": null, // in case if platform's JWKS endpoint somehow unavailable you may paste JWKS here
        "private_key_file" : "<path_to_private_key>", // Relative path to the tool's private key
        "public_key_file": "<path_to_public_key>", // Relative path to the tool's public key
        "deployment_ids" : ["<deployment_id>"] // The deployment_id passed by the platform during launch
    }, {
        "default": false,
        "client_id" : "<client_id2>",
        ...
    }]
}

and execute:

$ docker-compose up --build

You may use virtualenv instead of docker:

$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ cd game
$ python manage.py runserver 127.0.0.1:9001

Now there is game example tool you can launch into on the port 9001:

OIDC Login URL: http://127.0.0.1:9001/login/
LTI Launch URL: http://127.0.0.1:9001/launch/
JWKS URL: http://127.0.0.1:9001/jwks/