Legacy Knowledge Base
Published Jun. 30, 2025

(Cloud) 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 supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

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

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

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 SaaS Quarterly Release
  • Liferay PaaS Quarterly Release

Resolution

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

  • SaaS: this is automated - nothing needs to be done.
  • PaaS: there is a temporary documentation on how to implement this manually.

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base