# 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

**URL:** <https://community.mosip.io/t/im-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/1680>\
**Category:** Developer\
**Tags:** pre-registration\
**Created:** [November 18, 2024, 12:57pm UTC](https://community.mosip.io/t/im-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/1680 "2024-11-18T12:57:09Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manoj\_Manfred\_Billa](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/manoj_manfred_billa/32/1357_2.png) [@Manoj\_Manfred\_Billa](https://community.mosip.io/u/Manoj_Manfred_Billa)\
**Post date:** [November 18, 2024, 12:57pm UTC](https://community.mosip.io/t/im-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/1680/1 "2024-11-18T12:57:09Z")

</div>

- 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?

---

<div class="post-metadata">

**Author:** ![Vibha\_Gondkar](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/vibha_gondkar/32/1143_2.png) [@Vibha\_Gondkar](https://community.mosip.io/u/Vibha_Gondkar)\
**Post date:** [November 19, 2024, 5:36am UTC](https://community.mosip.io/t/im-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/1680/2 "2024-11-19T05:36:56Z")

</div>

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](https://docs.mosip.io/1.2.0/modules/pre-registration/pre-registration-developer-setup) for a detailed setup and [API documentation](https://docs.mosip.io/1.2.0/modules/pre-registration/pre-registration-developer-setup#pre-registration-api).

Best Regards,  
Team MOSIP

---

<div class="post-metadata">

**Author:** ![ymahtat](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/ymahtat/32/609_2.png) [@ymahtat](https://community.mosip.io/u/ymahtat)\
**Post date:** [November 20, 2024, 10:03am UTC](https://community.mosip.io/t/im-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/1680/3 "2024-11-20T10:03:10Z")

</div>

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**

---

<div class="post-metadata">

**Author:** ![Manoj\_Manfred\_Billa](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/manoj_manfred_billa/32/1357_2.png) [@Manoj\_Manfred\_Billa](https://community.mosip.io/u/Manoj_Manfred_Billa)\
**Post date:** [November 20, 2024, 12:28pm UTC](https://community.mosip.io/t/im-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/1680/4 "2024-11-20T12:28:12Z")

</div>

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:**

```auto
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](http://localhost:51000/config)

2. mosip.base.url=[http://localhost:8080](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.

---

<div class="post-metadata">

**Author:** ![Manoj\_Manfred\_Billa](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/manoj_manfred_billa/32/1357_2.png) [@Manoj\_Manfred\_Billa](https://community.mosip.io/u/Manoj_Manfred_Billa)\
**Post date:** [November 25, 2024, 9:28am UTC](https://community.mosip.io/t/im-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/1680/5 "2024-11-25T09:28:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Vibha\_Gondkar](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/vibha_gondkar/32/1143_2.png) [@Vibha\_Gondkar](https://community.mosip.io/u/Vibha_Gondkar)\
**Post date:** [November 25, 2024, 9:42am UTC](https://community.mosip.io/t/im-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/1680/6 "2024-11-25T09:42:38Z")

</div>

Hi @Manoj_Manfred_Billa ,

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

Best Regards,  
Team MOSIP

---

<div class="post-metadata">

**Author:** ![ymahtat](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/ymahtat/32/609_2.png) [@ymahtat](https://community.mosip.io/u/ymahtat)\
**Post date:** [December 3, 2024, 9:32am UTC](https://community.mosip.io/t/im-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/1680/7 "2024-12-03T09:32:18Z")

</div>

Hi [@Manoj\_Manfred\_Billa](https://community.mosip.io/u/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](https://docs.mosip.io/1.2.0/collab-getting-started-guide). 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**

---

<div class="post-metadata">

**Author:** ![Manoj\_Manfred\_Billa](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/manoj_manfred_billa/32/1357_2.png) [@Manoj\_Manfred\_Billa](https://community.mosip.io/u/Manoj_Manfred_Billa)\
**Post date:** [December 3, 2024, 1:00pm UTC](https://community.mosip.io/t/im-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/1680/8 "2024-12-03T13:00:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![svahsek](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/svahsek/32/1098_2.png) [@svahsek](https://community.mosip.io/u/svahsek)\
**Post date:** [December 4, 2024, 7:11am UTC](https://community.mosip.io/t/im-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/1680/9 "2024-12-04T07:11:05Z")

</div>

Dear @Manoj_Manfred_Billa ,

@ymahtat will be helping you with this shortly.

Regards  
Team MOSIP

---

<div class="post-metadata">

**Author:** ![ymahtat](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/ymahtat/32/609_2.png) [@ymahtat](https://community.mosip.io/u/ymahtat)\
**Post date:** [December 4, 2024, 12:53pm UTC](https://community.mosip.io/t/im-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/1680/10 "2024-12-04T12:53:41Z")

</div>

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](https://docs.mosip.io/1.2.0/deploymentnew/getting-started) 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](https://docs.mosip.io/1.2.0/collab-getting-started-guide/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 🙏

Best regards,  
**Team MOSIP**

---

<div class="post-metadata">

**Author:** ![Vibha\_Gondkar](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/vibha_gondkar/32/1143_2.png) [@Vibha\_Gondkar](https://community.mosip.io/u/Vibha_Gondkar)\
**Post date:** [December 4, 2024, 1:31pm UTC](https://community.mosip.io/t/im-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/1680/11 "2024-12-04T13:31:08Z")

</div>

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](https://docs.mosip.io/1.2.0/collab-getting-started-guide)
2. Pre-Registration Developer Setup Guide: [Pre-registration Developers Guide | MOSIP Docs 1.2.0](https://docs.mosip.io/1.2.0/modules/pre-registration/pre-registration-developer-setup)

Best Regards,  
Team MOSIP

---

<div class="post-metadata">

**Author:** ![Veera\_Ragavan](https://dub1.discourse-cdn.com/flex017/user_avatar/community.mosip.io/veera_ragavan/32/1380_2.png) [@Veera\_Ragavan](https://community.mosip.io/u/Veera_Ragavan)\
**Post date:** [December 10, 2024, 5:58am UTC](https://community.mosip.io/t/im-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/1680/12 "2024-12-10T05:58:45Z")

</div>

Hi @Manoj_Manfred_Billa  
I am facing the same issue. If that issue is resolved, please let me know.
