![](/img/trans.png)
[英]Fetching statements from Learning Locker LRS using TinCan API
[英]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®istration=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
您需要至少創建一個 Store 並在客戶端設置中指定它。
我對 Learning Locker 並不特別熟悉,但我不相信 Authorization 標頭的顯示值是正確的,至少不是我所期望的基於顯示的密鑰和秘密的值。 的 base64 編碼值:
NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjNDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpZWj4NymE0YTpZWj2Y4NYJVJ4NYJVJY4NYJVJYMZE
解碼為:
49417cbe3047c929bd9231e19c6bf0f6a7322a4A
其中似乎有一個額外的段c49417cbe3047c929bd9231e19c6bf0f6a7322a4a
您可以嘗試使用以下值的標頭:
NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4
這是基於密鑰和秘密然后base64編碼
49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c362eaea59f80201cecb48621ca20d66b06e8d18
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.