Cvmcosta / ltijs

Turn your application into a fully integratable LTI 1.3 tool provider.
https://cvmcosta.github.io/ltijs/
Apache License 2.0
299 stars 67 forks source link

Canvas - Failed sending grade to platform! HTTPError: Internal Server Error #78

Closed RaghavReddy closed 3 years ago

RaghavReddy commented 3 years ago

Describe the bug I'm running the Example Ltijs Server, when I click on "submit grade" I'm getting Failed sending grade to platform! HTTPError: Internal Server Error

Expected behavior Post grades to the canvas

Provider logs provider:main Attempting to connect to database +0ms provider:database Database connected +0ms provider:database Database connection open +3ms provider:main Ltijs started listening on port: 3000 +39ms


| | | | | | |/ __| | | | | | | | | (__
| | | | | |
| |_
\ | |_| | | |_ | || |) | |__|| |____()/|/

LTI Provider is listening on port 3000!

LTI provider config:

App Route: / Initiate Login Route: /login Keyset Route: /keys Session Timeout Route: /sessiontimeout Invalid Token Route: /invalidtoken

Starting in Dev Mode, state validation and session cookies will not be required. THIS SHOULD NOT BE USED IN A PRODUCTION ENVIRONMENT! provider:main Platform already registered +28ms provider:main Receiving request at path: /grade +7m provider:main Path does not match reserved endpoints +0ms provider:main Cookies received: +0ms provider:main [Object: null prototype] { provider:main 'ltiaHR0cHM6Ly9jYW52YXMuaW5zdHJ1Y3R1cmUuY29tMTYxMDgwMDAwMDAwMDAwMTA3MTUwOjY2Y2FjNTJkODY4N2UyZTBmYjJmOTM3ODc0YzM1ZjdlZTE5ZGU4YWU%3D': 'a711bf8e-7a3a-464b-952d-5cd48d142cfc' provider:main } +0ms provider:main LTIK found +1ms provider:main LTIK successfully verified +2ms provider:main Attempting to retrieve matching session cookie +0ms provider:main Dev Mode enabled: Missing session cookies will be ignored +0ms provider:auth Valid session found +0ms provider:main Passing request to next handler +16ms provider:gradeService Target platform: https://canvas.instructure.com +0ms provider:gradeService Attempting to retrieve platform access_token for [https://canvas.instructure.com] +3ms provider:platform Valid access_token for https://canvas.instructure.com not found +0ms provider:platform Attempting to generate new access_token for https://canvas.instructure.com +0ms provider:platform With scopes: https://purl.imsglobal.org/spec/lti-ags/scope/lineitem https://purl.imsglobal.org/spec/lti-ags/scope/score +0ms provider:auth Awaiting return from the platform +0ms Response code 500 (Internal Server Error)

Screenshots

image

Ltijs version

NodeJS version

Platform used

Additional context await lti.registerPlatform({ url: 'https://canvas.instructure.com', name: 'Canvas sandbox', clientId: 'XXXXXXXXX', authenticationEndpoint: 'https://kaplanlabs.instructure.com/api/lti/authorize_redirect', accesstokenEndpoint: 'https://kaplanlabs.instructure.com/login/oauth2/token', authConfig: { method: 'JWK_SET', key: 'https://kaplanlabs.instructure.com/api/lti/security/jwks' } })

Cvmcosta commented 3 years ago

Hello! I think your issue is that you are running your LTI Provider on localhost:

provider:platform Attempting to generate new access_token for https://canvas.instructure.com +0ms

In order to generate an access token, the Canvas instance has to reach your LTI Provider and retrieve the public key list, this doesn't work if you are running Ltijs on localhost on a different machine.

RaghavReddy commented 3 years ago

Thanks a lot for the quick response! really appreciate it.

dcheruiy commented 3 years ago

@RaghavReddy @Cvmcosta I am running into the same issue but I am running the app in the development server. Can you explain this a little more "In order to generate an access token, the Canvas instance has to reach your LTI Provider and retrieve the public key list"

Cvmcosta commented 3 years ago

Hello @dcheruiy! In order for the Platform to validate some requests it needs to reach the Tool's public key set, so this URL needs to be accessible from the Platform. If one of them is not accessible via the internet, the flow does not work.

dcheruiy commented 3 years ago

So if the platform is: canvas.instructure.com AND my LTI tool is running at example.com URL

How do I make example.com be accessible from canvas.instructure.com. Is there more configuration that needs to happen after I have created the LTI key and installed the Tool?

Thank you for your quick reply.

Cvmcosta commented 3 years ago

Are both of them accessible via the internet? What is the actual URL for the Canvas instance?

Cvmcosta commented 3 years ago

Trying to access the Tool URL gives me ERR_ADDRESS_UNREACHABLE. As long as both of them are accessible via the internet you shouldn't have issues related to that.

doldsimo commented 2 years ago

@Cvmcosta I get the same error. My error Message is Failed sending grade to platform! HTTPError: 500.

You mean that the canvas instance must be hostet on a server so that it is accessable from the internet, and the LTI App should also be accessable from the internet.

So my canvas instance ist hosted and accessible from the internet and my canvas LTI App is running over nkrog-tunnle, so it is also accessible. But I am getting the error message. When I use only localhost as you descibed before it is also not working.