Community

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
gmolter
New Member

LTI App - missing post params - custom_canvas_course_id and custom_canvas_api_domain

Jump to solution

Hi,

I'm trying to build an LTI app that extends the features currently offered in the course view. It needs to be available in every courses and work on multiple instances of Canvas (both self-hosted and instructure hosted).

I was able to add my app (on a instructure hosted instance) and it now displays in the course profile menu for admins like I wanted it to do.

I noticed that when my app is originally loaded canvas POST a whole bunch of information back to my app which is what you would expect. However I can't find a documented/preferred way :

a) to identify which instance of Canvas is loading the app. I suppose I should rely on the oauth_consumer_key. However how do I get to know the API url/path from that?

b) to identity from which course my app is currently being displayed in. According to some LTI documentation that should be the context_id. But at least in the instructure hosted instances the context_id is an MD5 hash that can't be reused in API calls.

Thank you for your help!

Labels (2)
Tags (4)
1 Solution

Accepted Solutions

Guillaume, is your tool public?  It looks like the "custom_canvas_api_domain" may only be returned for public tools.  I had to peak into the Canvas code.   It will be in canvas/gems/lti_outbound/lib/lti_outbound/tool_launch.rb, if you have your own copy.   Or you can browse to it here: canvas-lms/tool_launch.rb at stable · instructure/canvas-lms · GitHub 

(I may be wrong though - just guessing from the snippet I'm seeing on line 101...

View solution in original post

9 Replies
MattHanes
Community Member

You might want to ask this over in the Canvas Developers​ community. This generic community will just have a lot of people read your question like this:pirate.jpg

Thank you, I moved the question to the developer community.

hagimotk
New Member

Hi Guillaume,

YMMV, but here's what I see with our external tools.

a) One of the request parameter you get is "custom_canvas_api_domain".  We're hosted and get "oregonstate.instructure.com" as its value.

b) With the course navigation tool, I always see a request parameter "custom_canvas_course_id", which is the canvas internal ID for the course (and you also see this ID in the URL).  Depending on how you have things set up, there are also "context_label" and "context_title".  For us, this field contains the course ID that our institution uses and is also part SIS_COURSE_ID.

Hope this helps,

Kumi

Thanks for your help...unfortunatly I get none of those. Here is what I get (I have slighly altered the tokens and hashes):

Array

(

    [oauth_consumer_key] => a-consumer-key

    [oauth_signature_method] => HMAC-SHA1

    [oauth_timestamp] => 1439475972

    [oauth_nonce] => gljhxvQYY8sNzppT0IeTrtYGboqERw00000000

    [oauth_version] => 1.0

    [context_id] => 6dea912122e999239a4663d99fc96ee450000000

    [context_label] => A test course

    [context_title] => A test course

    [custom_canvas_enrollment_state] => inactive

    [ext_roles] => urn:lti:instrole:ims/lis/Administrator,urn:lti:role:ims/lis/Learner,urn:lti:sysrole:ims/lis/User

    [launch_presentation_document_target] => iframe

    [launch_presentation_height] => 400

    [launch_presentation_locale] => en

    [launch_presentation_return_url] => https://harvard-catalog-courses.instructure.com/courses/1/external_content/success/external_tool_red...

    [launch_presentation_width] => 800

    [lti_message_type] => basic-lti-launch-request

    [lti_version] => LTI-1p0

    [oauth_callback] => about:blank

    [resource_link_id] => 6dea912122e999239a4663d99fc96ee450000000

    [resource_link_title] => Photo Dir

    [roles] => Learner,urn:lti:instrole:ims/lis/Administrator

    [tool_consumer_info_product_family_code] => canvas

    [tool_consumer_info_version] => cloud

    [tool_consumer_instance_contact_email] => notifications@instructure.com

    [tool_consumer_instance_guid] => 00000000jjb2J1k3qsyAzb6E3SJLMwWL8zksTvSvH0:canvas-lms

    [tool_consumer_instance_name] => Harvard Catalog

    [user_id] => 000000005b785159ad8f8df15daf0ee0000000

    [oauth_signature] => ekq3cC4xBfa2TXQ9B4100000000

)

Interesting.. I get a whole lot more back from Canvas in my request.

Maybe you can try adding $Canvas.api.domain (See Variable Substitution: LTI from scratch (ruby) )

Like one poster says in this discussion:

   Substitution Variables in Canvas  https://groups.google.com/d/topic/canvas-lms-users/avudbjncu6s/discussion

, I also do not have to do this in order to get the "custom_canvas_api_domain".

Kumi

Guillaume, is your tool public?  It looks like the "custom_canvas_api_domain" may only be returned for public tools.  I had to peak into the Canvas code.   It will be in canvas/gems/lti_outbound/lib/lti_outbound/tool_launch.rb, if you have your own copy.   Or you can browse to it here: canvas-lms/tool_launch.rb at stable · instructure/canvas-lms · GitHub 

(I may be wrong though - just guessing from the snippet I'm seeing on line 101...

Haha! I just found out that the problem was the privacy. I was writing to let you know that I found the solution I guess you were faster than me :-). Indeed, if you set the privacy to Anonymous canvas will scrap a whole bunch of data of the post back.

I really which this was a little better documented in the user guides.

Anyway THANK YOU very much for your time and help!

Back to work now 🙂

I have also edited the title of the question to make it easier for others to find.

Glad I could help a little - I also wasn't aware of this, so it was good to find out!  (And I agree about the documentation.. it does take a little bit of poking around.)  🙂