简体   繁体   English

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

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

I've configured Learning Locker on AWS EC2 and using the already build community AMI with Ubuntu 16.04.我已经在 AWS EC2 上配置了 Learning Locker,并在 Ubuntu 16.04 上使用了已经构建的社区 AMI。 I can access the URL and can login into the system and play with it.我可以访问 URL 并可以登录系统并使用它。 I went in and created the client and using the default organization.我进去创建了客户端并使用默认组织。

I'm passing Authorization token as per documentation in my each of the request but I still get 401 unauthorized.我正在根据每个请求中的文档传递授权令牌,但我仍然得到 401 未经授权。

I even followed the support videos that are shared in the documentation for statements and state but they even didn't work for me.我什至遵循了文档中共享的支持视频,用于声明和状态,但它们甚至对我不起作用。

I'm sturggling on this from two days now, so assistance is required.从这两天开始我就在纠结这个,所以需要帮助。 I tried it using CURL and using Insomnia software but the response remained same.我使用 CURL 和 Insomnia 软件进行了尝试,但响应保持不变。 As I'm under test settings, so don't mind even sharing the exact tokens.由于我正在测试设置,因此甚至不介意共享确切的令牌。 And CURL requests.和 CURL 请求。

Here is the CURL request that I used这是我使用的 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"

Here is the response: {"errorId":"7fe46a1d-e46e-4a22-ad21-399c6bb16e6a","message":"Unauthorised"}这是响应: {"errorId":"7fe46a1d-e46e-4a22-ad21-399c6bb16e6a","message":"Unauthorised"}

The only call that succeeds is call to /data/xAPI/about , which gives the below response唯一成功的调用是调用/data/xAPI/about ,它给出以下响应

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

Learning Locker Status学习储物柜状态

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  │
└─────┴──────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

Learning Locker Logs学习储物柜日志

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

Can anyone tell me, what mistake I'm making over here?谁能告诉我,我在这里犯了什么错误? Please also go through the screenshots.还请浏览屏幕截图。 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

You'll need to create at least one Store and specify it in the client settings.您需要至少创建一个 Store 并在客户端设置中指定它。

  1. Log into your organization.登录您的组织。
  2. Select Settings > Stores.选择设置 > 商店。
  3. Click Add New (to add a new record store).单击新增(以添加新的记录存储)。
  4. Fill in the Name/Description.填写名称/说明。
  5. Then go back to your Clients menu.然后返回到您的客户菜单。
  6. Specify the LRS and Scope in the client details.在客户端详细信息中指定 LRS 和范围。

I'm not familiar specifically with Learning Locker, but I don't believe the displayed value for the Authorization header is correct, at least not what I would expect it to be based on the displayed key and secret.我对 Learning Locker 并不特别熟悉,但我不相信 Authorization 标头的显示值是正确的,至少不是我所期望的基于显示的密钥和秘密的值。 The base64 encoded value of:的 base64 编码值:

NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjNDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4 NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjNDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpZWj4NymE0YTpZWj2Y4NYJVJ4NYJVJY4NYJVJYMZE

Decodes to:解码为:

49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c362eaea59f80201cecb48621ca20d66b06e8d18 49417cbe3047c929bd9231e19c6bf0f6a7322a4A

Which appears to have an extra segment c49417cbe3047c929bd9231e19c6bf0f6a7322a4a其中似乎有一个额外的段c49417cbe3047c929bd9231e19c6bf0f6a7322a4a

You might try a header with the following value:您可以尝试使用以下值的标头:

NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4 NDk0MTdjYmUzMDQ3YzkyOWJkOTIzMWUxOWM2YmYwZjZhNzMyMmE0YTpjMzYyZWFlYTU5ZjgwMjAxY2VjYjQ4NjIxY2EyMGQ2NmIwNmU4ZDE4

Which is based on the key and secret then base64 encoded这是基于密钥和秘密然后base64编码

49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c362eaea59f80201cecb48621ca20d66b06e8d18 49417cbe3047c929bd9231e19c6bf0f6a7322a4a:c362eaea59f80201cecb48621ca20d66b06e8d18

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM