对于使用社区 EC2 AMI 机器的 Learning Locker,我总是使用 xAPI 获得 401 未经授权的响应

I always get 401 unauthorized response with xAPI for Learning Locker using community EC2 AMI machine

我已经在 AWS EC2 上配置了 Learning Locker,并使用 Ubuntu 16.04 已经构建的社区 AMI。我可以访问 URL 并可以登录系统并使用它。我进去创建了客户端并使用默认组织。

我根据每个请求中的文档传递授权令牌,但我仍然收到 401 未经授权。

我什至关注了声明和状态文档中共享的支持视频,但它们甚至对我不起作用。

两天来我一直在苦苦思索这个问题,所以需要帮助。我尝试使用 CURL 并使用 Insomnia 软件,但响应保持不变。因为我正在测试设置中,所以不介意分享确切的令牌。并且 CURL 请求。

这是我使用的 CURL 请求

curl -H "Authorization: Basic NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4" -H "X-Experience-API-Version: 1.0.3" -H "Content-Type: application/json" -X POST http://ec2-18-185-127-9.eu-central-1.compute.amazonaws.com/data/xAPI/activities/state --data "activityId=http%3A%2F%2Fwww.example.org%2Factivity&agent=%7B%22mbox%22%3A%20%22mailto%3Atest%40example.org%22%7D&stateId=example_state_id&registration=361cd8ef-0f6a-40d2-81f2-b988865f640c"

这是回复:{"errorId":"7fe46a1d-e46e-4a22-ad21-399c6bb16e6a","message":"Unauthorised"}

唯一成功的调用是对 /data/xAPI/about 的调用,它给出以下响应

{
"X-Experience-API-Version": "1.0.3",
"version": [
"1.0.3"
]
}

学习储物柜状态

ubuntu@ip-172-31-33-77:~$ sudo su learninglocker
learninglocker@ip-172-31-33-77:/home/ubuntu$ pm2 status
┌─────┬──────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name         │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ API          │ default     │ 2.0.0   │ cluster │ 1501     │ 47h    │ 0    │ online    │ 0.3%     │ 105.7mb  │ lea… │ enabled  │
│ 3   │ Scheduler    │ default     │ 2.0.0   │ cluster │ 1949     │ 47h    │ 0    │ online    │ 0%       │ 78.0mb   │ lea… │ enabled  │
│ 1   │ UIServer     │ default     │ 2.0.0   │ cluster │ 1502     │ 47h    │ 0    │ online    │ 0.3%     │ 80.2mb   │ lea… │ enabled  │
│ 2   │ Worker       │ default     │ 2.0.0   │ cluster │ 1910     │ 47h    │ 0    │ online    │ 0.3%     │ 106.3mb  │ lea… │ enabled  │
│ 4   │ xAPI         │ default     │ 0.0.0-… │ cluster │ 1978     │ 47h    │ 0    │ online    │ 0%       │ 70.9mb   │ lea… │ enabled  │
│ 5   │ xAPI         │ default     │ 0.0.0-… │ cluster │ 2027     │ 47h    │ 0    │ online    │ 0.3%     │ 71.6mb   │ lea… │ enabled  │
└─────┴──────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

学习储物柜日志

learninglocker@ip-172-31-33-77:/home/ubuntu$ pm2 logs xAPI
[TAILING] Tailing last 15 lines for [xAPI] process (change the value with --lines option)
/var/log/learninglocker/xapi_stdout-4.log last 15 lines:
4|xAPI     | 2020-04-22 10:28:57:549 - info: Listening on port 8081
4|xAPI     | 2020-04-22 10:28:57:553 - info: Process ready
4|xAPI     | 2020-04-22 10:28:57:600 - info: Created new Mongo connection
4|xAPI     | 2020-08-26 12:13:23:946 - info: Listening on port 8081
4|xAPI     | 2020-08-26 12:13:23:952 - info: Process ready
4|xAPI     | 2020-08-26 12:13:24:008 - info: Created new Mongo connection
4|xAPI     | 2020-08-26 19:57:44:805 - info: Created new Mongo connection

/var/log/learninglocker/xapi_stdout-5.log last 15 lines:
5|xAPI     | 2020-04-22 10:28:59:426 - info: Listening on port 8081
5|xAPI     | 2020-04-22 10:28:59:429 - info: Process ready
5|xAPI     | 2020-04-22 10:28:59:468 - info: Created new Mongo connection
5|xAPI     | 2020-08-26 12:13:23:943 - info: Listening on port 8081
5|xAPI     | 2020-08-26 12:13:23:952 - info: Process ready
5|xAPI     | 2020-08-26 12:13:24:014 - info: Created new Mongo connection
5|xAPI     | 2020-08-26 20:11:38:514 - info: Created new Mongo connection
5|xAPI     | 2020-08-27 15:01:13:192 - info: Created new Mongo connection

/var/log/learninglocker/xapi_stderr-5.log last 15 lines:
5|xAPI     | 2020-08-26 21:06:39:195 - error: 17200f4e-d98d-48ba-b09b-ea447fa68b05: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 21:14:59:778 - error: e9ae78fd-943a-4647-b310-ad101ba913d4: xapi-statements handled - Method (undefined) is invalid for alternate request syntax
5|xAPI     | 2020-08-26 21:42:05:999 - error: 078ef7b8-b33b-4280-8565-747994ed1e73: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 21:56:08:157 - error: c6a21e87-1215-4b04-91dd-b510b52d6364: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:02:50:626 - error: fd56c95b-b9c5-4178-8d18-6f35141490d6: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:03:25:201 - error: 1b38c501-449a-411e-a347-4dc9b2d642ca: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:11:56:776 - error: 651244b9-31ee-437c-abf5-7dbf2210e2a4: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:12:18:698 - error: d6cd8b7a-bd15-4692-84df-a5f3c3ec9b9f: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:13:04:239 - error: e9a37180-da2e-456b-8408-92817f78c9e3: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:24:04:922 - error: 7fe46a1d-e46e-4a22-ad21-399c6bb16e6a: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:33:49:707 - error: 49c9671e-b029-408b-8b81-cfcd38308fdb: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:46:18:820 - error: 4955d956-8b33-4be6-b3bd-3931f9249bae: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 22:49:33:257 - error: 4f0fadbf-122e-4412-8967-c5995bf74b35: jscommons handled - Unauthorised
5|xAPI     | 2020-08-26 23:48:56:248 - error: ed0c1692-f6b2-4190-9645-d09389c9cf9b: jscommons handled - Unauthorised
5|xAPI     | 2020-08-27 15:01:13:225 - error: 32028e87-e844-4a01-8136-a6a2a2ee53b9: jscommons handled - Unauthorised

/var/log/learninglocker/xapi_stderr-4.log last 15 lines:
4|xAPI     | 2020-08-26 21:08:32:861 - error: 4311e4ac-bdcd-4765-98db-a9292e8d921b: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 21:14:16:597 - error: 4a3dda4a-d5f9-49d5-b78f-1ab7b4bac731: xapi-statements handled - Method (undefined) is invalid for alternate request syntax
4|xAPI     | 2020-08-26 21:52:58:594 - error: 2dda9bd1-c1f2-4635-9ff6-f7865163824a: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 21:58:22:651 - error: f45b92c0-6403-439e-9783-0384d22a352b: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:03:16:466 - error: f4b494e2-6daf-485e-9c63-65febf4d1dab: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:11:45:122 - error: 0dcbcc49-2b69-45a2-91e8-e8d8422cbcc4: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:12:45:131 - error: d662c18e-8c0a-4efd-b3b5-9c13cc236c57: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:13:11:537 - error: da431a2c-a157-4695-a808-90381bf99113: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:25:27:984 - error: 53926e82-0d1f-45a2-8a70-f4c3b7c43e64: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:33:27:589 - error: 93e21ba1-0c06-4721-868f-6205b13a0009: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:35:41:287 - error: 7512a719-d25b-4852-a40e-9a8c6f5d2300: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 22:47:03:308 - error: 7a5aab9e-8675-4588-b720-ccf422f61f42: jscommons handled - Unauthorised
4|xAPI     | 2020-08-26 23:27:07:862 - error: c54e4396-33f3-4cfa-8141-79db6cfa130b: jscommons handled - Unauthorised

谁能告诉我,我在这里犯了什么错误?还请查看屏幕截图。

我不是特别熟悉 Learning Locker,但我不相信授权 header 的显示值是正确的,至少不是我基于显示的密钥所期望的值和秘密。 base64编码值:

NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjNDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4

解码为:

49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c362eaea59f80201cecb48621ca20d66b06e8d18

其中似乎有一个额外的片段 c49417cbe3047c929bd9231e19c6bf0f6a7322a4a

您可以尝试使用以下值的 header:

NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4

基于key和secret然后base64编码

49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c362eaea59f80201cecb48621ca20d66b06e8d18

您需要至少创建一个商店并在客户端设置中指定它。

  1. 登录您的组织。
  2. Select 设置 > 商店。
  3. 单击添加新(以添加新的记录存储)。
  4. 填写Name/Description.
  5. 然后返回您的客户菜单。
  6. 在客户端详细信息中指定 LRS 和范围。