I'm encountering an issue while starting the Pre-Registration Application Service. The application fails to obtain a token from the authentication service, leading to an unsuccessful startup

  • The service successfully fetches document category and type information.
  • An error occurs when requesting a token from the authentication service located at http:// localhost:8080/auth/realms/.
    
  • The error message indicates problems with the client ID and secret used for authentication.
    
  • The application ultimately fails to start due to the missing token.
    

I’d appreciate assistance in troubleshooting this issue. Could you please advise on the following:

  1. Are there any known issues with authentication configuration in the Pre-Registration Application Service?
  2. How can I verify the correctness of the client ID and secret used for authentication?
  3. Are there any additional steps I can take to diagnose the root cause of the token retrieval failure?

Hi @Manoj_Manfred_Billa ,

Welcome to the community! We are looking into this issue, and one of our experts will reach out to you shortly. Meanwhile, you can go through our comprehensive Pre-registration Developers’s guide for a detailed setup and API documentation.

Best Regards,
Team MOSIP

Hi @Manoj_Manfred_Billa,

Thank you for reaching out. Based on your description, I believe the issue might be related to the following areas :

1. Client ID and Client Secret Configuration :
The error message suggests an issue with the Client ID or Client Secret. It would be helpful to confirm if the credentials used for authentication are accurate and match those configured in the Authentication Service.

2. Environment Configuration :
Please verify that the realm, authentication URLs, and environment variables (e.g., CLIENT_ID, CLIENT_SECRET) are correctly set up in the Pre-Registration Application.

3. Connectivity Between Services :
Ensure there are no network or connectivity issues between the Pre-Registration Application Service and the Authentication Service. Logs related to network requests might help identify potential problems.

For further investigation, could you please provide the following details ?

  • Log traces from the Pre-Registration Application Service, especially any error messages or stack traces related to authentication.
  • Any additional context, such as recent changes to the system configuration or authentication setup.

These details will help us narrow down the root cause and propose a solution.

Looking forward to your response.

Best regards,
MOSIP Team

Hi @ymahtat ,

Pre-Registration Application Service Logs

Timestamp: 2024-11-18 18:11:36.579+05:30
Log Level: INFO
Message:
getAllDocCategoriesAndTypes url: http://localhost:8080/v1/masterdata/validdocuments/all?pageSize=50
Logger Name: io.mosip.preregistration.core.util.ValidationUtil
Thread Name: restartedMain
App Name: pre-registration-application-service


Timestamp: 2024-11-18 18:11:36.627+05:30
Log Level: INFO
Message:
Requesting for new Token for the provided OIDC Service: http://localhost:8080/auth/realms/
Logger Name: io.mosip.kernel.auth.defaultadapter.helper.TokenHelper
Thread Name: restartedMain
App Name: pre-registration-application-service
Trace ID: 913031a8cc64e4eb
Span ID: 913031a8cc64e4eb


Timestamp: 2024-11-18 18:11:36.645+05:30
Log Level: ERROR
Message:
error connecting to auth service
Logger Name: io.mosip.kernel.auth.defaultadapter.helper.TokenHelper
Thread Name: restartedMain
App Name: pre-registration-application-service
Trace ID: 913031a8cc64e4eb
Span ID: 913031a8cc64e4eb


Timestamp: 2024-11-18 18:11:36.647+05:30
Log Level: ERROR
Message:
there is some issue with getting token with clientId and secret
Logger Name: io.mosip.kernel.auth.defaultadapter.config.SelfTokenRestInterceptor
Thread Name: restartedMain
App Name: pre-registration-application-service
Trace ID: 913031a8cc64e4eb
Span ID: 913031a8cc64e4eb


Timestamp: 2024-11-18 18:11:36.655+05:30
Log Level: INFO
Message:
Error starting ApplicationContext. To display the conditions report, re-run your application with 'debug' enabled.
Logger Name: org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener
Thread Name: restartedMain
App Name: pre-registration-application-service


Timestamp: 2024-11-18 18:11:36.663+05:30
Log Level: ERROR
Message:
Application run failed
Logger Name: org.springframework.boot.SpringApplication
Thread Name: restartedMain
Stack Trace:

io.mosip.kernel.auth.defaultadapter.exception.AuthAdapterException: Self cached auth token is null  
	at io.mosip.kernel.auth.defaultadapter.config.SelfTokenRestInterceptor.intercept(SelfTokenRestInterceptor.java:71)  
	at org.springframework.http.client.InterceptingClientHttpRequest$InterceptingRequestExecution.execute(InterceptingClientHttpRequest.java:92)  
	...

App Name: pre-registration-application-service


Timestamp: 2024-11-18 18:11:36.666+05:30
Log Level: INFO
Message:
Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@581dd551: startup date [Mon Nov 18 18:11:18 IST 2024]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@5a2a1ca3
Logger Name: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext
Thread Name: restartedMain
App Name: pre-registration-application-service


Timestamp: 2024-11-18 18:11:36.691+05:30
Log Level: INFO
Message:
HikariPool-1 - Shutdown initiated...
Logger Name: com.zaxxer.hikari.HikariDataSource
Thread Name: restartedMain
App Name: pre-registration-application-service


Timestamp: 2024-11-18 18:11:36.695+05:30
Log Level: INFO
Message:
HikariPool-1 - Shutdown completed.
Logger Name: com.zaxxer.hikari.HikariDataSource
Thread Name: restartedMain
App Name: pre-registration-application-service


Application Properties :

  1. spring.cloud.config.uri= http://localhost:51000/config

  2. mosip.base.url=http://localhost:8080

  3. application.id: pre-registration

  4. Also Created a new application in the authentication service and generated a Client ID and Client Secret.

  • Replaced the old credentials with the new Client ID and Secret in the application properties.

hi @ymahtat & @Vibha_Gondkar ,
Could you Please look into this issue?

Hi @Manoj_Manfred_Billa ,

We are looking into this issue and will get back to you shortly.

Best Regards,
Team MOSIP

Hi @Manoj_Manfred_Billa ,
Apologies for the delayed response. The issue occurs because the Pre-Registration Application Service depends on external modules (e.g., Masterdata, Authentication) to function. Running it locally without access to these services leads to token retrieval and startup failures.
Recommended Solutions:

  1. For Exploring the Application (Demo Mode): We recommend using the demo environment. These demo environments are pre-configured with all dependent services, allowing you to experience the application as intended to function.

  2. For Exploring the Code: If your objective is to explore the code or understand the service:
    – You can clone the Pre-Registration application’s codebase, build it locally, and review the code structure and logic.
    – However, running the application locally requires access to environments where the dependent services (Masterdata, Authentication, etc.) are hosted and accessible to you.
    – If you have access to such an environment, update the application.properties file with the relevant service URLs (e.g., spring.cloud.config.uri and mosip.base.url).
    – Without these services, the application cannot start successfully.

Best regards,
Team MOSIP

Hi @ymahtat,

Sure, could you please let me know where I can find these services and what exactly they entail?

Also, I am running the Config Server locally and plan to update the spring.cloud.config.uri in the application.properties file with the corresponding local link. Please confirm if there are any additional steps I need to follow.

Dear @Manoj_Manfred_Billa ,

@ymahtat will be helping you with this shortly.

Regards
Team MOSIP

Hi @Manoj_Manfred_Billa,
Thank you for your patience,

Here are the details based on your questions :

  1. Finding the Required Services :
    The necessary services, such as Masterdata, Authentication, and others, are part of the MOSIP ecosystem and must be accessible for the Pre-Registration application to function properly.
    If you’re running the application locally, you need to ensure that you have access to these services. These services are typically part of the full MOSIP setup, and you can check the Deployement Getting Started Documentation for more details about the setup.
    Again, If your goal is to experience the application in Demo Mode (see Demo Environment Documentation), we recommend using the demo environment at collab.mosip.net. You can refer to the Collab Pre-Registration Guide for detailed instructions on using the environment.

  2. Config Server Setup :
    You’re correct in planning to update the spring.cloud.config.uri in the application.properties file to point to your locally running Config Server.
    – Additionally, make sure your Config Server is properly configured with all the necessary files for the Pre-Registration application. These include configurations that point to the required dependent services.
    – For local setup, you’ll need to update the application.properties file with the correct URLs for services like Masterdata, Authentication, and others. You can refer to the Pre-Registration Developer Setup Guide for more detailed instructions on configuring these services locally.

Let me know if you need further assistance or have additional questions :pray:

Best regards,
Team MOSIP

Hi @Manoj_Manfred_Billa ,

For detailed information based on @ymahtat 's inputs. Please refer to the below Documentation:

  1. Demo Environment Documentation: Collab Environment Guides | MOSIP Docs 1.2.0
  2. Pre-Registration Developer Setup Guide: Pre-registration Developers Guide | MOSIP Docs 1.2.0

Best Regards,
Team MOSIP