question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issues with Hosted LTIJS server

See original GitHub issue

Describe the bug I moved the LTIJS server code to a hosted server and trying to integrate with a Localhost Moodle and having an Unauthorized 401 error.

Expected behavior I am expecting it to read the LTIKEY properly and authenticate the request. Provider logs

lti
> dynoslti@1.0.0 start /use/src/app
lti
> env DEBUG=provider:* node index.js
lti
environment variables...
lti
LTIKEY
lti
dynosadmin
lti
2020-10-19T04:58:13.929Z provider:main Attempting to connect to database
lti
2020-10-19T04:58:14.287Z provider:database Database connected
lti
2020-10-19T04:58:14.287Z provider:database Database connection open
lti
2020-10-19T04:58:14.293Z provider:main Ltijs started listening on port: 3000
lti
_ _______ _____ _ _____
lti
| | |__ __|_ _| | |/ ____|
lti
| | | | | | | | (___
lti
| | | | | | _ | |\___ \
lti
| |____| | _| |_| |__| |____) |
lti
|______|_| |_____|\____/|_____/
lti
LTI Provider is listening on port 3000!
lti
LTI provider config:
lti
>App Route: /
lti
>Initiate Login Route: /login
lti
>Keyset Route: /keys
lti
>Session Timeout Route: /sessiontimeout
lti
>Invalid Token Route: /invalidtoken
lti
Starting in Dev Mode, state validation and session cookies will not be required. THIS SHOULD NOT BE USED IN A PRODUCTION ENVIRONMENT!
lti
2020-10-19T04:58:14.430Z provider:main Platform already registered
lti
-----BEGIN PUBLIC KEY-----
lti
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwjYuHsWBQRH8ori9+cbF
lti
ov7am78z8xotcEOx0r9w4Rz3R5ReS8K8Y54vWZGIX/qlQQvdJ5vXBjxMjz8PCtRw
lti
mM0PMLdQO3kkn/meCZlb//GsIJaOCP6zbFoAIz7IkyEJJ3dtILIgsSiR5zu5aPyV
lti
/5lUGm2Z2zQGlZbzH9GhuAVMBOx7qk4P5FNs1GZXenQSHyq+bB5EJ9eqmurEoZUb
lti
lSypE//AzTGP+9JXInT9tkeBqrqOrXFgEtrZB+rCrqOLvXBy9zFtWt0i3YIepWWx
lti
DQoodv9Vti2/e9E2uLEtviVraSwwec6jN1ry716Z1zys+4+sx3CDLt3b3hhfW5OV
lti
Dl8JzcWcHuAJIy4KIy+YxKXkDxHM/oRxLqq1Tj5fdSnrw12wO0meCQFuLoSjdxou
lti
/SE1ueBCRB6r+ILID7V/HuU93fu/tgC8K7OHR0KmM1wWWHGcfe8phde5r1K78DEg
lti
amZa4lRgidPBX4ucMtGDm0mdrdazxH1j0R3bNn6YD8Ql8oCyw26gh+DdxnU9HFzE
lti
aW2b1yDp7SDW+mX9PGGwCYbEF+9JH0O1wPa7GP7ieGnjNctJ8HCj/kblBCjjXBF6
lti
aYoAIFlPzTl4PlYiqM2jQEEVh7PeanfIsIXU2gPUY697BWWQkuHsHbuo8VoOmMnz
lti
x/fE5zw3OImEhcUX8Mgr0hcCAwEAAQ==
lti
-----END PUBLIC KEY-----
lti
Deployed!
lti
2020-10-19T04:58:55.942Z provider:main Receiving request at path: /login
lti
2020-10-19T04:58:55.943Z provider:main Receiving a login request from: http://localhost
lti
2020-10-19T04:58:55.962Z provider:main Redirecting to platform authentication endpoint
lti
2020-10-19T04:58:55.962Z provider:main Target Link URI: https://stg-lti.dynos.io
lti
2020-10-19T04:58:55.963Z provider:main Login request:
lti
2020-10-19T04:58:55.966Z provider:main {
lti
response_type: 'id_token',
lti
response_mode: 'form_post',
lti
id_token_signed_response_alg: 'RS256',
lti
scope: 'openid',
lti
client_id: 'sWZ99TqdxZnkXqC',
lti
redirect_uri: 'https://stg-lti.dynos.io',
lti
login_hint: '2',
lti
nonce: 'tnab8bh49xqwbhc2b0d4i68us',
lti
prompt: 'none',
lti
state: '675daef7e498e773123fc795e2058888e3db7da9e5c339992a',
lti
lti_message_hint: '5',
lti
lti_deployment_id: '2'
lti
}
lti
2020-10-19T04:58:56.853Z provider:main Receiving request at path: /
lti
2020-10-19T04:58:56.853Z provider:main Path does not match reserved endpoints
lti
2020-10-19T04:58:56.853Z provider:main Cookies received:
lti
2020-10-19T04:58:56.854Z provider:main [Object: null prototype] {}
lti
2020-10-19T04:58:56.854Z provider:main Received idtoken for validation
lti
2020-10-19T04:58:56.854Z provider:auth Response state: 675daef7e498e773123fc795e2058888e3db7da9e5c339992a
lti
2020-10-19T04:58:56.856Z provider:auth Attempting to validate iss claim
lti
2020-10-19T04:58:56.856Z provider:auth Request Iss claim: undefined
lti
2020-10-19T04:58:56.857Z provider:auth Response Iss claim: http://localhost
lti
2020-10-19T04:58:56.857Z provider:auth Dev Mode enabled: Missing state validation cookies will be ignored
lti
2020-10-19T04:58:56.857Z provider:auth Attempting to retrieve registered platform
lti
2020-10-19T04:58:56.872Z provider:auth Retrieving key from jwk_set
lti
2020-10-19T04:59:00.035Z provider:main Deleting state cookie and Database entry
lti
2020-10-19T04:59:00.055Z provider:auth RequestError: connect ECONNREFUSED 127.0.0.1:80
lti
at ClientRequest. (/use/src/app/node_modules/got/dist/source/core/index.js:957:25)
lti
at Object.onceWrapper (events.js:421:26)
lti
at ClientRequest.emit (events.js:326:22)
lti
at ClientRequest.origin.emit (/use/src/app/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
lti
at Socket.socketErrorListener (_http_client.js:428:9)
lti
at Socket.emit (events.js:314:20)
lti
at emitErrorNT (internal/streams/destroy.js:92:8)
lti
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
lti
at processTicksAndRejections (internal/process/task_queues.js:84:21)
lti
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
lti
2020-10-19T04:59:00.056Z provider:main Passing request to invalid token handler
lti
2020-10-19T04:59:00.160Z provider:main Receiving request at path: /invalidtoken
lti
2020-10-19T04:59:21.434Z provider:main Receiving request at path: /login
lti
2020-10-19T04:59:21.434Z provider:main Receiving a login request from: http://localhost
lti
2020-10-19T04:59:21.450Z provider:main Redirecting to platform authentication endpoint
lti
2020-10-19T04:59:21.450Z provider:main Target Link URI: https://stg-lti.dynos.io
lti
2020-10-19T04:59:21.450Z provider:main Login request:
lti
2020-10-19T04:59:21.450Z provider:main {
lti
response_type: 'id_token',
lti
response_mode: 'form_post',
lti
id_token_signed_response_alg: 'RS256',
lti
scope: 'openid',
lti
client_id: 'sWZ99TqdxZnkXqC',
lti
redirect_uri: 'https://stg-lti.dynos.io',
lti
login_hint: '2',
lti
nonce: 'k279crznlzireb0zqxut9aj0a',
lti
prompt: 'none',
lti
state: 'a1d02b511a967c096b05e1bfc42be52c892cce60f713b6cdda',
lti
lti_message_hint: '5',
lti
lti_deployment_id: '2'
lti
}
lti
2020-10-19T04:59:22.407Z provider:main Receiving request at path: /
lti
2020-10-19T04:59:22.407Z provider:main Path does not match reserved endpoints
lti
2020-10-19T04:59:22.407Z provider:main Cookies received:
lti
2020-10-19T04:59:22.407Z provider:main [Object: null prototype] {}
lti
2020-10-19T04:59:22.407Z provider:main Received idtoken for validation
lti
2020-10-19T04:59:22.407Z provider:auth Response state: a1d02b511a967c096b05e1bfc42be52c892cce60f713b6cdda
lti
2020-10-19T04:59:22.408Z provider:auth Attempting to validate iss claim
lti
2020-10-19T04:59:22.408Z provider:auth Request Iss claim: undefined
lti
2020-10-19T04:59:22.408Z provider:auth Response Iss claim: http://localhost
lti
2020-10-19T04:59:22.408Z provider:auth Dev Mode enabled: Missing state validation cookies will be ignored
lti
2020-10-19T04:59:22.408Z provider:auth Attempting to retrieve registered platform
lti
2020-10-19T04:59:22.423Z provider:auth Retrieving key from jwk_set
lti
2020-10-19T04:59:25.513Z provider:main Deleting state cookie and Database entry
lti
2020-10-19T04:59:25.528Z provider:auth RequestError: connect ECONNREFUSED 127.0.0.1:80
lti
at ClientRequest. (/use/src/app/node_modules/got/dist/source/core/index.js:957:25)
lti
at Object.onceWrapper (events.js:421:26)
lti
at ClientRequest.emit (events.js:326:22)
lti
at ClientRequest.origin.emit (/use/src/app/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
lti
at Socket.socketErrorListener (_http_client.js:428:9)
lti
at Socket.emit (events.js:314:20)
lti
at emitErrorNT (internal/streams/destroy.js:92:8)
lti
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
lti
at processTicksAndRejections (internal/process/task_queues.js:84:21)
lti
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
lti
2020-10-19T04:59:25.528Z provider:main Passing request to invalid token handler
lti
2020-10-19T04:59:25.601Z provider:main Receiving request at path: /invalidtoken
lti
2020-10-19T05:06:24.955Z provider:main Receiving request at path: /
lti
2020-10-19T05:06:24.955Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:06:24.955Z provider:main Cookies received:
lti
2020-10-19T05:06:24.955Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:06:24.956Z provider:main Accessing as whitelisted route
lti
2020-10-19T05:07:13.690Z provider:main Receiving request at path: /
lti
2020-10-19T05:07:13.690Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:07:13.690Z provider:main Cookies received:
lti
2020-10-19T05:07:13.690Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:07:13.691Z provider:main Accessing as whitelisted route
lti
2020-10-19T05:07:13.758Z provider:main Receiving request at path: /main
lti
2020-10-19T05:07:13.758Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:07:13.758Z provider:main Cookies received:
lti
2020-10-19T05:07:13.758Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:07:13.758Z provider:main No ltik found
lti
2020-10-19T05:07:13.758Z provider:main Request body: {}
lti
2020-10-19T05:07:13.758Z provider:main Passing request to invalid token handler
lti
2020-10-19T05:07:13.825Z provider:main Receiving request at path: /invalidtoken
lti
2020-10-19T05:09:05.241Z provider:main Receiving request at path: /
lti
2020-10-19T05:09:05.241Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:09:05.241Z provider:main Cookies received:
lti
2020-10-19T05:09:05.241Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:09:05.241Z provider:main Accessing as whitelisted route
lti
2020-10-19T05:09:05.306Z provider:main Receiving request at path: /main
lti
2020-10-19T05:09:05.306Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:09:05.306Z provider:main Cookies received:
lti
2020-10-19T05:09:05.306Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:09:05.306Z provider:main No ltik found
lti
2020-10-19T05:09:05.306Z provider:main Request body: {}
lti
2020-10-19T05:09:05.306Z provider:main Passing request to invalid token handler
lti
2020-10-19T05:09:05.369Z provider:main Receiving request at path: /invalidtoken
lti
2020-10-19T05:09:29.450Z provider:main Receiving request at path: /login
lti
2020-10-19T05:09:29.451Z provider:main Receiving a login request from: http://localhost
lti
2020-10-19T05:09:29.634Z provider:main Redirecting to platform authentication endpoint
lti
2020-10-19T05:09:29.635Z provider:main Target Link URI: https://stg-lti.dynos.io
lti
2020-10-19T05:09:29.635Z provider:main Login request:
lti
2020-10-19T05:09:29.635Z provider:main {
lti
response_type: 'id_token',
lti
response_mode: 'form_post',
lti
id_token_signed_response_alg: 'RS256',
lti
scope: 'openid',
lti
client_id: 'sWZ99TqdxZnkXqC',
lti
redirect_uri: 'https://stg-lti.dynos.io',
lti
login_hint: '2',
lti
nonce: 'kik3wc6ekq1exq00tsnjs0dlo',
lti
prompt: 'none',
lti
state: '5e52b6335424d210dc6f45b3b7280f478918f32cf8ea739e64',
lti
lti_message_hint: '5',
lti
lti_deployment_id: '2'
lti
}
lti
2020-10-19T05:09:30.481Z provider:main Receiving request at path: /
lti
2020-10-19T05:09:30.482Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:09:30.482Z provider:main Cookies received:
lti
2020-10-19T05:09:30.482Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:09:30.482Z provider:main Received idtoken for validation
lti
2020-10-19T05:09:30.482Z provider:auth Response state: 5e52b6335424d210dc6f45b3b7280f478918f32cf8ea739e64
lti
2020-10-19T05:09:30.484Z provider:auth Attempting to validate iss claim
lti
2020-10-19T05:09:30.484Z provider:auth Request Iss claim: undefined
lti
2020-10-19T05:09:30.484Z provider:auth Response Iss claim: http://localhost
lti
2020-10-19T05:09:30.484Z provider:auth Dev Mode enabled: Missing state validation cookies will be ignored
lti
2020-10-19T05:09:30.484Z provider:auth Attempting to retrieve registered platform
lti
2020-10-19T05:09:30.498Z provider:auth Retrieving key from jwk_set
lti
2020-10-19T05:09:33.545Z provider:main Deleting state cookie and Database entry
lti
2020-10-19T05:09:33.559Z provider:auth RequestError: connect ECONNREFUSED 127.0.0.1:80
lti
at ClientRequest. (/use/src/app/node_modules/got/dist/source/core/index.js:957:25)
lti
at Object.onceWrapper (events.js:421:26)
lti
at ClientRequest.emit (events.js:326:22)
lti
at ClientRequest.origin.emit (/use/src/app/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)
lti
at Socket.socketErrorListener (_http_client.js:428:9)
lti
at Socket.emit (events.js:314:20)
lti
at emitErrorNT (internal/streams/destroy.js:92:8)
lti
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
lti
at processTicksAndRejections (internal/process/task_queues.js:84:21)
lti
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1145:16)
lti
2020-10-19T05:09:33.559Z provider:main Passing request to invalid token handler
lti
2020-10-19T05:09:33.628Z provider:main Receiving request at path: /invalidtoken
lti
2020-10-19T05:14:35.441Z provider:main Receiving request at path: /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
lti
2020-10-19T05:14:35.441Z provider:main Path does not match reserved endpoints
lti
2020-10-19T05:14:35.441Z provider:main Cookies received:
lti
2020-10-19T05:14:35.441Z provider:main [Object: null prototype] {}
lti
2020-10-19T05:14:35.441Z provider:main No ltik found
lti
2020-10-19T05:14:35.441Z provider:main Request body: [Object: null prototype] { '' }
lti
2020-10-19T05:14:35.441Z provider:main Passing request to invalid token handler
lti
2020-10-19T05:14:35.717Z provider:main Receiving request at path: /invalidtoken
lti
2020-10-19T05:18:26.856Z provider:main Receiving request at path: /invalidtoken

Screenshots Here’s a screenshot of the settings: https://prnt.sc/v21we1

Ltijs version Latest

NodeJS version

  • Version 12

Platform used

  • Localhost Moodle

Additional context We are seeing this error on the launch: https://prnt.sc/v21x59

Here’s our setup:

// Setup
lti.setup(process.env.LTI_KEY,
  {
    url: 'mongodb+srv://cluster0.ekibo.mongodb.net/' + process.env.DB_NAME,
    connection: { user: process.env.DB_USER, pass: process.env.DB_PASS }
  }, {
    staticPath: path.join(__dirname, './public'), // Path to static files
    cookies: {
      secure: false, // Set secure to true if the testing platform is in a different domain and https is being used
      sameSite: '', // Set sameSite to 'None' if the testing platform is in a different domain and https is being used
      domain: '.dynos.io'
    },
    devMode: true // Set DevMode to true if the testing platform is in a different domain and https is not being used
  })

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
GreenOncommented, Oct 19, 2020

Yes, if I use non-localhost environment for the platform, it authenticates correctly. I am proceeding further with integration now. Thanks a lot! I also turned off the dev mode.

    cookies: {
      secure: true, // Set secure to true if the testing platform is in a different domain and https is being used
      sameSite: 'None', // Set sameSite to 'None' if the testing platform is in a different domain and https is being used
      domain: '.tool'
    },
    devMode: false // Set DevMode to true if the testing platform is in a different domain and https is not being used
1reaction
GreenOncommented, Oct 19, 2020

I see. Let me try the https://sandbox.moodledemo.net/ instead of localhost to see if it works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Are there any known issues with using LTI 1.3 with self-hosted ...
I am working on an LTI 1.3 tool. To test Canvas integration, I have set up a Canvas LMS in our Amazon Web...
Read more >
Ltijs NPM | npm.io
This library implements a tool provider as an Express server, with preconfigured routes and methods that manage the LTI® 1.3 protocol for you....
Read more >
Learning Tools Interoperability Core Specification 1.3 - 1EdTech
Examples of tools might include an externally hosted testing system or a server that contains externally hosted premium content.
Read more >
ltijs-sequelize | Object-Relational Mapping library
Implement ltijs-sequelize with how-to, Q&A, fixes, code snippets. kandi ... const setup = async () => { // Deploy server and open connection...
Read more >
A Roadmap to Convert Educational Web Applications into LTI ...
cases where a student launches an activity from the LMS, solves it in the external ... ltijs. TSUGI LtiLibrary ims-lti lti-1-3. Maturity. First...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found