我正在用 Python 开发一个 LTI 工具提供程序,并且在 LTI 1.x 基本启动工作或内容项规范的任何方面都没有问题。尽管尝试使用 LTI 2 注册机制,但我遇到了巨大的障碍。
每当我在某些工具使用者上运行我的代码时,当我将工具代理发布到工具使用者配置文件中列出的工具代理端点时,我得到的只是 400 错误。
我试过这个:
- http://lti.tools/test/tc.php(注册成功)
- 在 AWS 上运行的 Moodle 3.2(400 错误请求)
- Moodle 3.3 在本地主机上运行(成功注册)
- 画布(400 错误请求){“错误”:“无效功能”}
不幸的是,没有什么能让我知道这个请求有什么不好的地方。我 90% 确定它是 JSON 或标题中的内容。我很确定它不是 oAuth(感谢下面的评论以及它在 4 个测试环境中的 2 个中工作的事实)
据说 Moodle 在某处为您提供了一些输出,但我到处寻找并没有找到它。我从站点管理员菜单打开了开发模式,并遵循了几个关于如何确保在 PHP 中记录错误并且我在任何地方都找不到任何内容的说明。
最初我无法让它在任何地方工作,但我能够将 xdebug 连接到本地 Moodle 3.3 实例,这就是我最终能够让它工作的方式。
这是来自 Canvas 的工具消费者资料:
{'@context':
['http://purl.imsglobal.org/ctx/lti/v2/ToolConsumerProfile'],
'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9',
'@type': 'ToolConsumerProfile',
'capability_offered': ['basic-lti-launch-request',
'User.id',
'Canvas.api.domain',
'LtiLink.custom.url',
'ToolProxyBinding.custom.url',
'ToolProxy.custom.url',
'Canvas.placements.accountNavigation',
'Canvas.placements.courseNavigation',
'Canvas.placements.assignmentSelection',
'Canvas.placements.linkSelection',
'Canvas.placements.postGrades',
'User.username',
'Person.email.primary',
'vnd.Canvas.Person.email.sis',
'Person.name.given',
'Person.name.family',
'Person.name.full',
'CourseSection.sourcedId',
'Person.sourcedId',
'Membership.role',
'ToolConsumerProfile.url',
'Security.splitSecret',
'Context.id',
'ToolConsumerInstance.guid',
'CourseSection.sourcedId',
'Membership.role',
'Person.email.primary',
'Person.name.given',
'Person.name.family',
'Person.name.full',
'Person.sourcedId',
'User.id',
'User.image',
'Message.documentTarget',
'Message.locale',
'Context.id',
'vnd.Canvas.root_account.uuid'],
'guid': '339b6700-e4cb-47c5-a54f-3ee0064921a9',
'lti_version': 'LTI-2p0',
'product_instance': {'guid': '07adb3e60637ff02d9ea11c7c74f1ca921699bd7.canvas.instructure.com',
'product_info': {'product_family': {'code': 'canvas',
'vendor': {'code': 'https://instructure.com',
'timestamp': '2008-03-27T06:00:00Z',
'vendor_name': {'default_value': 'Instructure',
'key': 'vendor.name'}}},
'product_name': {'default_value': 'Canvas '
'by '
'Instructure',
'key': 'product.name'},
'product_version': 'none'},
'service_owner': {'description': {'default_value': 'Free '
'For '
'Teachers',
'key': 'service_owner.description'},
'service_owner_name': {'default_value': 'Free '
'For '
'Teachers',
'key': 'service_owner.name'}}},
'security_profile': [{'digest_algorithm': 'HMAC-SHA1',
'security_profile_name': 'lti_oauth_hash_message_security'},
{'digest_algorithm': 'HS256',
'security_profile_name': 'oauth2_access_token_ws_security'}],
'service_offered': [{'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9#ToolProxy.collection',
'@type': 'RestService',
'action': ['POST'],
'endpoint': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_proxy',
'format': ['application/vnd.ims.lti.v2.toolproxy+json']},
{'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9#ToolProxy.item',
'@type': 'RestService',
'action': ['GET'],
'endpoint': 'https://canvas.instructure.com/api/lti/tool_proxy/{tool_proxy_guid}',
'format': ['application/vnd.ims.lti.v2.toolproxy+json']},
{'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9#vnd.Canvas.authorization',
'@type': 'RestService',
'action': ['POST'],
'endpoint': 'https://canvas.instructure.com/api/lti/courses/1146163/authorize',
'format': ['application/json']},
{'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9#ToolProxySettings',
'@type': 'RestService',
'action': ['GET', 'PUT'],
'endpoint': 'https://canvas.instructure.com/api/lti/tool_settings/tool_proxy/{tool_proxy_id}',
'format': ['application/vnd.ims.lti.v2.toolsettings+json',
'application/vnd.ims.lti.v2.toolsettings.simple+json']},
{'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9#ToolProxyBindingSettings',
'@type': 'RestService',
'action': ['GET', 'PUT'],
'endpoint': 'https://canvas.instructure.com/api/lti/tool_settings/bindings/{binding_id}',
'format': ["application/vnd.ims.lti.v2.toolsettings+json'",
'application/vnd.ims.lti.v2.toolsettings.simple+json']},
{'@id': 'https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile/339b6700-e4cb-47c5-a54f-3ee0064921a9#LtiLinkSettings',
'@type': 'RestService',
'action': ['GET', 'PUT'],
'endpoint': 'https://canvas.instructure.com/api/lti/tool_settings/links/{tool_proxy_id}',
'format': ['application/vnd.ims.lti.v2.toolsettings+json',
'application/vnd.ims.lti.v2.toolsettings.simple+json']}]}
这是我要发回的工具代理(我试图拉出任何看起来可选的东西。)
POST https://canvas.instructure.com/api/lti/courses/1146163/tool_proxy
{
"@type": "ToolProxy",
"@context": "http://purl.imsglobal.org/ctx/lti/v2/ToolProxy",
"tool_proxy_guid": "339b6700-e4cb-47c5-a54f-3ee0064921a9",
"tool_consumer_profile": "https://canvas.instructure.com/api/lti/courses/1146163/tool_consumer_profile",
"tool_profile": {
"base_url_choice": [
{
"default_base_url": "http://localhost:9090/",
"secure_base_url": "http://localhost:9090/",
"selector": {
"applies_to": [
"IconEndpoint",
"MessageHandler"
]
}
}
],
"lti_version": "LTI-2p0",
"product_instance": {
"guid": "1431963455",
"service_owner": {
"service_owner_name": {
"key": "service_owner.name",
"default_value": "EHR Tutor"
},
"description": {
"key": "service_owner.description",
"default_value": "Provider of high quality education"
},
"timestamp": "2017-05-04T05:37:35-05:00"
},
"product_info": {
"product_name": {
structure.com/api/lti/courses/1146163/tool_proxy/339b6700-e4cb-47c5-a54f-3ee0064921a9"\n}'
"key": "tool.name",
"default_value": "EHR Tutor"
},
"description": {
"key": "tool.description",
"default_value": "EHR Tutor"
},
"product_family": {
"vendor": {
"description": {
"key": "tool.vendor.description",
"default_value": "Noggin LLC"
},
"contact": {
"email": "info@ehrtutor.com"
},
"code": "ehrtutor.com",
"timestamp": "2017-05-04T05:37:35-05:00",
"website": "https://www.ehrtutor.com",
"vendor_name": {
"key": "tool.vendor.name",
"default_value": "Noggin LLC"
}
},
"code": "assessment-tool",
"@id": "https://my.ehrtutor.com"
},
"product_version": "0.0.1b",
"technical_description": {
"key": "tool.technical",
"default_value": "Support provided for LTI 2"
}
},
"support": {
"email": "support@ehrtutor.com"
},
"service_provider": {
"description": {
"key": "service_provider.description",
"default_value": "Service Host Provider"
},
"guid": "1431963455",
"support": {
"email": "support@ehrtutor.com"
},
"service_provider_name": {
"key": "service_provider.name",
"default_value": "EHR Tutor"
},
"timestamp": "2017-05-04T05:37:35-05:00"
}
},
"resource_handler": [
{
"resource_name": {
"key": "lesson.resource.name",
"default_value": "EHR Tutor App Launcher"
},
"description": {
"key": "lesson.resource.description",
"default_value": "Launch the EHR Tutor Application"
},
"message": [
{
"message_type": "basic-lti-launch-request",
"path": "lti",
"parameter": [
{
"variable": "User.id",
"name": "user_id"
},
{
"variable": "Person.name.given",
"name": "lis_person_name_given"
},
{
"variable": "Person.name.family",
"name": "lis_person_name_family"
},
{
"variable": "Person.name.full",
"name": "lis_person_name_full"
},
{
"variable": "Person.email.primary",
"name": "lis_person_contact_email_primary"
},
{
"variable": "Membership.role",
"name": "roles"
},
{
"variable": "Context.id",
"name": "context_id"
},
{
"variable": "Context.title",
"name": "context_title"
},
{
"variable": "ResourceLink.title",
"name": "resource_link_title"
},
{
"variable": "CourseSection.sourcedId",
"name": "lis_course_section_sourcedid"
}
]
}
],
"resource_type": {
"code": "lesson"
}
}
]
},
"lti_version": "LTI-2p0",
"security_contract": {
"shared_secret": "lgvupYnu5kaCFMWzLZkWhoKPbRaF89oyPGbTzaTwiYFpe3_c4xdQ2B-CW4-pAQeedzXxKf8h0J-T2O5tjxzFFA=="
},
"@id": "https://canvas.instructure.com/api/lti/courses/1146163/tool_proxy/339b6700-e4cb-47c5-a54f-3ee0064921a9"
}