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.