doldsimo / lti-1.3-canvas-lms

lti-1.3-canvas-lms
https://doldsimo.github.io/lti-1.3-canvas-lms/
MIT License
22 stars 1 forks source link

How to deploy LTI-1.3-canvas-lms in eduappcenter? #2

Closed bhavintce closed 1 year ago

bhavintce commented 1 year ago

As per the readme setup locally using ngrok and it's working fine in the local machine. Now i want to publish my app in edu app center.

performed Step -Create edu app center account. -Admin section Configuration create XML. (My app is resource app so added only resource part. Please review my XML configuration https://www.eduappcenter.com/configurations/s4jad10k84qvkbxz.xml) -Create app and fill basic details. -Submit time generate (https://www.eduappcenter.com/configurations/s4jad10k84qvkbxz.xml) XML URL. -Try to install this app in my canvas domain but getting below errors.

{"status":401,"error":"Unauthorized","details":{"description":"No Ltik or ID Token found.","message":"NO_LTIK_OR_IDTOKEN_FOUND","bodyReceived":{"oauth_consumer_key":"N/A","oauth_signature_method":"HMAC-SHA1","oauth_timestamp":"1691476570","oauth_nonce":"HB43bkdLxUlTUsmjXPjoqxCLLavln7GvBPcUt7gT80","oauth_version":"1.0","context_id":"9881e26effc6941d3ee7b519fe4aa70add6635d1","context_label":"JavaScript","context_title":"JavaScript","custom_canvas_enrollment_state":"active","ext_content_intended_use":"navigation","ext_content_return_types":"lti_launch_url","ext_content_return_url":"https://canvas.tecoreng.com/courses/1/external_content/success/external_tool_dialog","ext_roles":"urn:lti:instrole:ims/lis/Administrator,urn:lti:instrole:ims/lis/Instructor,urn:lti:role:ims/lis/Instructor,urn:lti:sysrole:ims/lis/SysAdmin,urn:lti:sysrole:ims/lis/User","launch_presentation_document_target":"iframe","launch_presentation_height":"500","launch_presentation_locale":"en-GB","launch_presentation_return_url":"https://canvas.tecoreng.com/courses/1/external_content/success/external_tool_dialog","launch_presentation_width":"500","lti_message_type":"basic-lti-launch-request","lti_version":"LTI-1p0","oauth_callback":"about:blank","resource_link_id":"9881e26effc6941d3ee7b519fe4aa70add6635d1","resource_link_title":"eFlok-08Aug-0001","roles":"Instructor,urn:lti:instrole:ims/lis/Administrator,urn:lti:sysrole:ims/lis/SysAdmin","selection_directive":"select_link","tool_consumer_info_product_family_code":"canvas","tool_consumer_info_version":"cloud","tool_consumer_instance_contact_email":"canvas@example.com","tool_consumer_instance_guid":"07UZznJ51F9yKAY81ryJXgIOMjYyLencmTnAnEuq:canvas-lms","tool_consumer_instance_name":"My site","user_id":"7ec98e027a42a4e84dbd62fa6f665e025c9fdf1d","oauth_signature":"het+8HFANu7NHERqk7jFVWe/Og0="}}}

Can you please help me how to solve this error?

doldsimo commented 1 year ago

Hi @bhavintce,

thanks for the new issue.

Unfortunately I have to tell you that I didn't publish my app in the Edu app store at the time. That said, I can't exactly help you with the configuration in the Edu App store. But I think you only have to publish or register your application in the Edu app store, but before that you have to deploy the app to a public server (not ngrok tunnel).

However, for test reasons, I hosted my app on a public server at the time, so that I had a ready-to-deploy app that interacted with Canvas (without always having to run it locally on my computer, as when developing.) My understanding of the Edu App store is that if you want to publish your app on the Edu App store, you either way have to publish/host the app on a server you provide. It is also important here that this server can be accessed normally via SSL. (like local via ngrok) At that time I used Heroku to test it, which worked. (I hosted my LTI app there) But you can use any hosting provider like aws or something else.

It is important to say here that you now have to deploy the MongoDB database online as well. I used the free client MongoDB Atlas for testing (which is free to use, so perfect for testing). If you do this, it is important that you then also adjust the connection url within your app or your .env file so that correct communication with the DB and your app can take place.

In summary I think the steps would be:

  1. Deploy your application with database and frontend to a server that can be accessed via SSL
  2. Try the deployte App in your or several Canvas instances
  3. Register the app on the Edu App store

I know that answer does not perfectly fit you specific question but maybe will help you to publish you app at the Edu app store.

How exactly does the 401 error message come about?

In your canvas instance you have now used which configuration parameters? Still the local ngrok tunnel? As soon as you want to use the application in the Edu App store, you should host your application on the web like a normal app.

I hope I could help, let me know how you continue and whether it works or where you have problems.

bhavintce commented 1 year ago

Thanks doldsimo for your quick response. Let me deploy the app on a public server and try.

bhavintce commented 1 year ago
const setup = async () => {
  await lti.deploy({ port: process.env.PORT })
  await lti.registerPlatform({
    url: process.env.CANVAS_BASE_URL, 
    name: process.env.CANVAS_DOMAIN_NAME,
    clientId: process.env.CANVAS_APP_CLIENT_ID, 
    authenticationEndpoint: process.env.CANVAS_BASE_URL+'/api/lti/authorize_redirect',
    accesstokenEndpoint: process.env.CANVAS_BASE_URL+'/login/oauth2/token',
    authConfig: {
       method: 'JWK_SET', 
       key: process.env.CANVAS_BASE_URL+'/api/lti/security/jwks' 
      }
  });
}

@doldsimo I have tried to deploy the node react project on the server. My question is how to manage this dynamic canvas platform URL. Because when we change the URL that time flush all Mongo DB without flushing our tool not working.

When we deploy publicly at that time users of different domains self-hosting this scenario how to manage it? (Same as clientId different on public panel that time how to get this?)

doldsimo commented 1 year ago

Hi @bhavintce,

I think what you are searching is a solution to register multiple canvas instances to use the lti plugin. This is not something this example repository is solving or providing out of the box. Because this example use ltijs you have to dive a little deeper in this library.

I found this solution to support multiple Canvas instances. I think this sould work in your example. So you have to extend the backend integration, with multiple register methods. Maybe check also some other issues from ltijs to this topic.

I hope this will help you.

bhavintce commented 1 year ago

Hi doldsimo

Thank you for your support.