legacy-knowledge-base
公開されました Sep. 10, 2025

Spring Boot Client Extension fails with [invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0

written-by

Rita Schaff

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • We have a Spring Boot extension client that interacts with the Liferay APIs and that makes the OAuth2 challenge via

  • OAuth2AccessToken oAuth2AccessToken = liferayOAuth2AccessTokenManager.getOAuth2AccessToken(clientRegistrationId);
  • When we launch the Spring Boot application via bootRun the OAuth2 Challenge is done without problem

  • When we launch the Spring Boot application via
    java -jar spring-boot-client-extension.jar
    we receive this error:

  • 2024-09-05 15:12:40.482 DEBUG 80178 --- [main]            : HTTP POST http://localhost:8080/o/oauth2/token
    2024-09-05 15:12:40.483 DEBUG 80178 --- [main]            : Accept=[application/json, application/*+json]
    2024-09-05 15:12:40.484 DEBUG 80178 --- [main]            : Writing [{grant_type=[client_credentials], client_id=[id-da997878-ba98-79d5-d494-9fa68e7daf0], client_secret=[<secret>]}] as "application/x-www-form-urlencoded;charset=UTF-8"
    2024-09-05 15:12:40.492 DEBUG 80178 --- [main]            : Response 401 UNAUTHORIZED
    2024-09-05 15:12:40.499 ERROR 80178 --- [main]     : Error during the import : [invalid_token_response] An error occurred while attempting to retrieve the OAuth 2.0 Access Token Response: 401 : [no body]

Environment

  • Liferay environment details, as well as third party and/or recent changes to environment that are relevant

Resolution

  • Running the task via bootRun actually appends 2 environment variables which reference directories that contain the necessary information to the process.

  • In a self-hosted environment, you need to implement this with something like a shell script that sets the environment variables, then runs the java process.

  • Furthermore, if the Client Extension microservice process is running on a separate system than the Liferay process, then you need to implement a feature to share the ${liferay.home}/routes directory across systems (using something like NFS, sshfs, etc.)

Additional Information

did-this-article-resolve-your-issue

legacy-knowledge-base