Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue While Creating User in Step 5 of Sunbird ED Setup - keycloak_local_setup.md #1257

Open
Ganesh-Protean opened this issue Mar 9, 2025 · 11 comments

Comments

@Ganesh-Protean
Copy link

5.Steps to create default system admin user and other tenant users

We have successfully completed the first four steps of setting up Sunbird ED, but we are encountering an issue when trying to create a user in Step 5.

Request payload:

curl --location --request POST 'localhost:9000/v1/ssouser/create' \
--header 'Content-Type: application/json' \
--header 'x-authenticated-user-token: #'access_token' value from above CURL response' \
--data-raw '{
    "request": {
        "firstName": "Test",
        "lastName": "user",
        "channel": "sunbird",
        "userName": "testuser",
        "email":"testuser@test.com",
        "emailVerified": true,
        "password": "Test@123",
        "userType": "teacher"
    }
}'

**The process fails with the following error message:**
{
    "id": "api.ssouser.create",
    "ver": "v1",
    "ts": "2025-03-09 13:42:10:514+0530",
    "params": {
        "resmsgid": "91452732-2e6d-40b0-a574-6d2d5d00af0f",
        "msgid": "91452732-2e6d-40b0-a574-6d2d5d00af0f",
        "err": "UOS_USRCRTnull",
        "status": "FAILED",
        "errmsg": "userType config is empty for the statecode default"
    },
    "responseCode": "CLIENT_ERROR",
    "result": {}
}
@GayathriSrividya
Copy link

Hi @Ganesh-Protean, could you use the API mentioned in the screenshot in Step 5? I'm sharing the curl for your reference:

[Link to GitHub repository](https://github.com/Sunbird-Lern/userorg-service/blob/master/keycloak_local_setup/keycloak_local_setup.md#steps-to-create-default-system-admin-user-and-other-tenant-users)

curl --location 'localhost:9000/v1/user/create' \
--header 'Content-Type: application/json' \
--header 'x-authenticated-user-token: #access_token value from the above CURL response' \
--data-raw '{
    "request": {
        "firstName": "Test",
        "lastName": "User",
        "channel": "sunbird",
        "userName": "testuser",
        "email": "testuser@test.com",
        "emailVerified": true,
        "password": "Test@123",
        "userType": "teacher"
    }
}'

@Ganesh-Protean
Copy link
Author

Hi @Ganesh-Protean, could you use the API mentioned in the screenshot in Step 5? I'm sharing the curl for your reference:

[Link to GitHub repository](https://github.com/Sunbird-Lern/userorg-service/blob/master/keycloak_local_setup/keycloak_local_setup.md#steps-to-create-default-system-admin-user-and-other-tenant-users)

curl --location 'localhost:9000/v1/user/create'
--header 'Content-Type: application/json'
--header 'x-authenticated-user-token: #access_token value from the above CURL response'
--data-raw '{
"request": {
"firstName": "Test",
"lastName": "User",
"channel": "sunbird",
"userName": "testuser",
"email": "testuser@test.com",
"emailVerified": true,
"password": "Test@123",
"userType": "teacher"
}
}'

Hi @Ganesh-Protean, could you use the API mentioned in the screenshot in Step 5? I'm sharing the curl for your reference:

[Link to GitHub repository](https://github.com/Sunbird-Lern/userorg-service/blob/master/keycloak_local_setup/keycloak_local_setup.md#steps-to-create-default-system-admin-user-and-other-tenant-users)

curl --location 'localhost:9000/v1/user/create'
--header 'Content-Type: application/json'
--header 'x-authenticated-user-token: #access_token value from the above CURL response'
--data-raw '{
"request": {
"firstName": "Test",
"lastName": "User",
"channel": "sunbird",
"userName": "testuser",
"email": "testuser@test.com",
"emailVerified": true,
"password": "Test@123",
"userType": "teacher"
}
}'

Hi @GayathriSrividya

We have tried using the revised API endpoint but still getting the same error. Please check & help us to resolve the same as soon as possible.

@GayathriSrividya
Copy link

Hi @Ganesh-Protean Could you please provide more context so we can debug the issue more efficiently? This error typically occurs when the organization and location are not properly created, as these are required inputs beforehand.

To assist us in resolving the issue as quickly as possible, could you kindly provide the following:

  • Which APIs have you interacted with from setup to user creation? (For example, organization, channel, location, etc.)
  • What is the branch of the user org service, and what other services have you installed as part of the setup?
  • What do the logs in the user org application show when the API is hit?

cc: @maheshkumargangula

@Ganesh-Protean
Copy link
Author

Hi @GayathriSrividya ,

We have resolved the issue related to creating the user in the database. However, as per the documentation, the user is also supposed to be registered in Keycloak, but that is not happening. The response we're getting is as follows:

{ "id": "api.ssouser.create", "ver": "v1", "ts": "2025-03-10 09:50:25:725+0530", "params": { "resmsgid": "3432852b-346a-4536-a6ac-74b85b042e8c", "msgid": "3432852b-346a-4536-a6ac-74b85b042e8c", "err": null, "status": "SUCCESS", "errmsg": null }, "responseCode": "OK", "result": { "response": "SUCCESS", "errors": [] } }

Let us know if you have any insights on why Keycloak registration is not being triggered.

We are currently blocked and unable to move forward due to the issue could we schedule a quick call to review and address the issue?

@GayathriSrividya
Copy link

GayathriSrividya commented Mar 10, 2025

Could you please explain how you verified user creation in Keycloak from your side? If the Keycloak user creation fails, the API will not ideally return a success message. Here are two ways to verify:

First, get the user ID you just created. This will be a UUID generated and set by the API. Use the following curl command:

curl --location 'http://localhost:9000/v1/user/get/email/<user_email>' \
--header 'Authorization: {{kong_api_key}}' \
--header 'Content-Type: application/json'

If successful, the response should contain the userId.

Another method is to go to the PostgreSQL database that Keycloak is using. There, you will find a table named federated_user. If you query this table, you can find the user ID. it will in format f:cassandrafederationid:<user_id>

The third method is to port-forward Keycloak and go to the user section. Since users are managed by the plugin, you cannot see the list directly. In the search bar of the user section, type the full username (not firstname or lastname) (e.g., "testuser") and hit enter.

I will share screenshots on my side for your reference.

Image Image

@HarishGangula
Copy link

@Ganesh-Protean
As discussed, Please the Keycloak env's , Modified changes in the lern code base and error logs to look into it.

cc: @GayathriSrividya

@Ganesh-Protean
Copy link
Author

@HarishGangula
@GayathriSrividya

As mentioned earlier also we are getting success response, no error logs are there.

@HarishGangula
Copy link

@Ganesh-Protean We need answers to the question asked here and the details asked here, without which we won't be able to proceed further on this issue.

Provide the proper details to check the issue further

@Ganesh-Protean
Copy link
Author

@HarishGangula
@GayathriSrividya

  1. We have ran all the APIs - create channel, create organization, create location.

  2. ⁠We are using master branch across all the services.

  3. ⁠There is no error logs, which are coming while creating the user.

  4. We’re currently on SB-7.0 of the ED portal.

  5. We’ve only made cosmetic changes so far, no changes to the DB yet.

  6. Repo url - https://github.com/Protean-Sunbird-Morocco/Sunbird-Morocco-Sandbox.git

  7. All the pods are running. The issue is with the local setup, and we need that fixed to move forward.

  8. The URL to access is this link. - https://gcp-dev.sunbirded.org/
    6.User is unable to register in keyclock .

@GayathriSrividya
Copy link

GayathriSrividya commented Mar 11, 2025

@Ganesh-Protean,
Could you clarify the changes made in step 5? The reason I'm asking is that if user registration fails in Keycloak, the API is expected to throw an error rather than a success response. If errors are being handled in the changes you made, the API might not function as expected.
Also for user org service setup, please use release-7.0.0 branch

I also suggest rebuilding the provider JAR located at keycloak-email-phone-authenticator-1.0-SNAPSHOT.jar.
Rebuild Instructions

@GayathriSrividya
Copy link

GayathriSrividya commented Mar 11, 2025

@Ganesh-Protean, I am also unable to access the URL: https://github.com/Protean-Sunbird-Morocco/Sunbird-Morocco-Sandbox.git. Could you please clarify the Keycloak environment, as discussed yesterday and mentioned here: #1257 (comment)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants