TokenRequestFailedException when trying to access destinations with OAuth2ClientCredentials type Authentication
Issue Description
We are trying to connect to say a microserviceB from microserviceA. The destination is configured with OAuth2ClientCredentials authentication. We have a certificate which we have added in the destination and a clientId. We have url to call B and a token service url.
Expectation is that the microserviceA sdk library will make a connection to the destination with DestinationAccessor.getDestination(name) and internally generate the token with the tokenUrl and call the url to microserviceB.
But when the code - DestinationAccessor.getDestination(name); is called, I get the following exception.
com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: com.sap.cloud.sdk.cloudplatform.resilience.ResilienceRuntimeException: com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: com.sap.cloud.sdk.cloudplatform.security.exception.TokenRequestFailedException: Failed to resolve access token.
I can generate a token via client and call the microserviceB via a client.
Impact / Priority
Its a P1 - top priority for us as our code freeze for go live is on 22 August.
Affected development phase: Development closure soon
Impact: Blocked
Timeline: e.g. Go-Live is in 4 weeks
Error Message
com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: com.sap.cloud.sdk.cloudplatform.resilience.ResilienceRuntimeException: com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: com.sap.cloud.sdk.cloudplatform.security.exception.TokenRequestFailedException: Failed to resolve access token.
- SDK Version: 5.0.0
- Link to GitHub repo:
- Project type, for example:
- [ ] CAP Project
- Platform: both below
- [ ] Cloud Foundry
- [ ] Deploy with Confidence (Cloud Foundry)
Checklist
- [ ] Checked out the documentation and Stack Overflow
- [ ] Description provided with all relevant information
- [ ] Exception and stack trace provided
- [ ] Attached debug logs
- [ ] Attached dependency tree
- [ ] Provided Cloud SDK version & link to relevant source code
Please provide the information as described in the issue template: full stack trace, logs etc.
Also, please upgrade to the latest version 5.11.0
Added the logs StackTrace.txt
Updated version to - 5.11.0
However, I get the following error on making a call to DestinationAccessor.getDestination(name);
com.sap.scl.tcl.client.GCLClient : Entering GlobalContentLibrary- getPublishedTemplateDto method 2024-08-19T09:00:25.642+0000 [APP/PROC/WEB/0] STDOUT 2024-08-19T09:00:25.642Z INFO 8 --- [nio-8080-exec-1] com.sap.scl.tcl.client.GCLClient : Entering performGetRequestForGCLWithCerts 2024-08-19T09:00:25.642+0000 [APP/PROC/WEB/0] STDOUT 2024-08-19T09:00:25.642Z INFO 8 --- [nio-8080-exec-1] com.sap.scl.tcl.client.GCLClient : Entering getDestination to get Destinations-gcl 2024-08-19T09:00:25.760+0000 [APP/PROC/WEB/0] STDOUT 2024-08-19T09:00:25.760Z INFO 8 --- [nio-8080-exec-1] com.sap.scl.tcl.client.GCLClient : Exception while getPublishedTemplateDto --Failed to determine com.sap.cloud.sdk.cloudplatform.resilience.ResilienceDecorationStrategy. 2024-08-19T09:00:25.760+0000 [APP/PROC/WEB/0] STDOUT 2024-08-19T09:00:25.760Z INFO 8 --- [nio-8080-exec-1] com.sap.scl.tcl.client.GCLClient : Exiting performGetRequestForGCL for method getPublishedTemplateDto
updating my destination configuration.
removed the image.
Hi @anupriyaSap,
Could you please attach full stack trace and DEBUG logs from your application?
We need DEBUG logs enabled for packages com.sap.cloud.sdk and org.apache.http.wire. Refer here for more details.
Please remove any sensitive information from the wire logs before sharing them.
Regards, Kavitha
Hi @anupriyaSap,
From the stack trace shared over email, I see the following root cause:
STDERR Caused by: java.lang.NoClassDefFoundError: javax/cache/configuration/Configuration
Please check your project's dependency tree and see if an older version of javax.cache:cache-api gets included.
Inside the SDK, we use javax.cache:cache-api:1.1.1. You could also use our BOM in your dependency management section to minimise dependency conflicts.
Also, since you mentioned you updated to version 5 recently and use DwC, please also check if you did all the steps listed here during migration.
Regards, Kavitha
Closing, assuming the issue is resolved