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

Consumer javascript implementation for comment #53

Open
sachss opened this issue Apr 4, 2016 · 0 comments
Open

Consumer javascript implementation for comment #53

sachss opened this issue Apr 4, 2016 · 0 comments

Comments

@sachss
Copy link

sachss commented Apr 4, 2016

Hi everyone,

I've had a go at implementing the Consumer class in Javascript, reusing as much code as I could from the published Javascript Provider class. I'm short on time right now to bring this to the proper format for a PR, especially because I'm not versed in Coffeescript, but I'd really appreciate comments on the approach.

Also welcome any help bringing this to good enough condition for a pull request.

Implementation:

    var lti = require( 'ims-lti' );
    var consumer = new lti.Consumer( 'oauth_key', 'oauth_secret' );
    var requestBody = {
        lti_version     : 'LTI-1p0',
        lti_message_type: 'basic-lti-launch-request',
        resource_link_id: '0',
        resource_link_title: 'My title',
        context_id: '1234',
        context_title: "My Test",
        context_label: "No label",
        roles: 'Student'
    };
    var ltiUrl = 'https://lti.source.com/launch';
    consumer.validate_request( requestBody, function( err, valid ) {
        if( err || ! valid ) next( err || new Error( "Invalid LTI request" ) );
        else {
            consumer.send( { url: ltiUrl }, function( err, msg, response ) {
                res.send( response );
            }
        }
    }

consumer.js

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

1 participant