Cvmcosta / ltijs

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

Selfhosted Canvas reports "Invalid redirect_uri" #69

Closed ChiefGnome closed 3 years ago

ChiefGnome commented 3 years ago

I can register my tool with Moodle, but if I try to register it with my self hosted canvas I get the following error message:

while(1);{"status":"bad_request","message":"Invalid redirect_uri","error_report_id":46}

The target link URL has been added to the Canvas developer key.

The debug log shows the request from canvas.instructure.com, but nothing else.


  provider:main Receiving a login request from: https://canvas.instructure.com +0ms
  provider:main Redirecting to platform authentication endpoint +4ms
  provider:main Target Link URI:  https://xxxxxxxxxxxxxxx/lti +0ms
  provider:main Login request:  +0ms
  provider:main {
  provider:main   response_type: 'id_token',
  provider:main   response_mode: 'form_post',
  provider:main   id_token_signed_response_alg: 'RS256',
  provider:main   scope: 'openid',
  provider:main   client_id: '10000000000002',
  provider:main   redirect_uri: 'https://xxxxxxxxxxxx/lti',
  provider:main   login_hint: '4c2e10446e824efddda2694fdecbf06345d6bdf7',
  provider:main   nonce: 't461ex83bxmwj4xe07b5672dc',
  provider:main   prompt: 'none',
  provider:main   state: 'ca959744d3d3944fe83ac4917cae968eb9e88ba06904213037',
  provider:main   lti_message_hint: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ2ZXJpZmllciI6IjkyMDBhNDRmZWVlNmUzYTNjOTZhY2UzMzViZmMxM2QxNzZkMjljZWZmNDhmNjU4YjBkM2JiNDM0ODZlNThkNWJmNjIwZWIyNjczYzYxMDNmZjUzNDllYTRmZGEwZDQ5NmE2NTU2NTkxMjA5ZDg0OGEyZDZmNjU4ODM5NWRkYzI5IiwiY2FudmFzX2RvbWFpbiI6ImNhbnZhcy5nZ25vLm1lIiwiY29udGV4dF90eXBlIjoiQWNjb3VudCIsImNvbnRleHRfaWQiOjEwMDAwMDAwMDAwMDAyLCJleHAiOjE2MDc5NjEzMTZ9.0K6gOrYUFn5tCwI6FLZ_T1dVPKPWsjyw7PSdTZN_jtM'
  provider:main } +0ms```
Cvmcosta commented 3 years ago

Hello! Did you set your application URL as a redirect URL in canvas? You should set https://xxxxxxxxxxxxxxx/lti as a redirect URL.

Also have in mind that changes made to developer keys are not applied to the apps, you have to delete the apps and recreate them in order for the changes to be applied.

ChiefGnome commented 3 years ago

Hello! Thank you for the fast reply! I have added the correct redirect URI and made some other changes, I guess now I am one step closer... Canvas now reports:

while(1);{"errors":[{"message":"An error occurred.","error_code":"internal_server_error"}],"error_report_id":90}

If I remove the URI I get the previous error.

Cvmcosta commented 3 years ago

Ahh yes, this error is common on self hosted Canvas instances, it is often caused by a misconfiguration during Canvas installation.

How did you install Canvas? You should consider a few things:

ChiefGnome commented 3 years ago

I use Bitnami Canvas, so this explains it. Thank you! What would be the easiest way to get canvas running, to just test the LTI connection?

Cvmcosta commented 3 years ago

I believe that going through the Production Installation of Canvas might be the most reliable way. Have in mind that you need to do both the Cache configuration and Dynamic settings configuration in order for LTI to work properly.

Cvmcosta commented 3 years ago

I'll be closing this issue for now since the initial problem was identified and it is not related to Ltijs.

GTMtremolo commented 3 years ago

Hi @Cvmcosta , can you send a config example for me, I have set config but my canvas still log error: {"message":"An error occurred.","error_code":"internal_server_error"}

Cvmcosta commented 3 years ago

This error still indicates issues with the Canvas Installation. How is your Canvas set up?

GTMtremolo commented 3 years ago

I install it from source.

This is dynamic_settings.yml file

production:

tree

config:

service

canvas:
  # environment
  canvas:
    encryption-secret: "astringthatisactually32byteslong"
    signing-secret: "astringthatisactually32byteslong"
  datadog-rum:
    application_id: "27627d1e-8a4f-4645-b390-bb396fc83c81"
    client_token: "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r"
    sample_rate_percentage: 0.0 # Between 0.0 and 100.0; 0.0 disables the feature.
  live-events:
    aws_endpoint: http://kinesis.canvaslms.docker
    kinesis_stream_name: live-events
  live-events-subscription-service:
    app-host: "http://les.docker"
    sad-panda: null
  math-man:
    base_url: 'http://mathman.docker'
    use_for_svg: 'false'
    use_for_mml: 'false'
  rich-content-service:
    app-host: "rce.docker"
  common_cartridge_viewer:
    base_url: "http://localhost:3300"
  fullstory:
    sampling_rate: '0.0' # randomly inject this fraction of the time
    app_key: 'xyzzy'
# another service
inst-fs:
  app-host: "http://api.instfs.docker"
  # this is just "super-sekret-value", base64-encoded:
  secret: "c3VwZXItc2VrcmV0LXZhbHVlCg=="
pandata:
  ios-pandata-key: IOS_pandata_key
  ios-pandata-secret: teamrocketblastoffatthespeedoflight
  android-pandata-key: ANDROID_pandata_key
  android-pandata-secret: surrendernoworpreparetofight

private: canvas: auditors.yml: | write_paths:

GTMtremolo commented 3 years ago

Hi @Cvmcosta, I have fixed this by turn on Redis cache. Thank you for your support