Search code examples
lrsxapilearning-locker

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. I can access the URL and can login into the system and play with it. 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.

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. As I'm under test settings, so don't mind even sharing the exact tokens. And CURL requests.

Here is the CURL request that I used

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"}

The only call that succeeds is call to /data/xAPI/about, which gives the below response

{
"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. enter image description here enter image description here enter image description here


Solution

  • You'll need to create at least one Store and specify it in the client settings.

    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.