oracle / oracle/oci-java-sdk

Failure to handle OCI authentication in /bmc-examples/src/main/java/CreateInstanceExample.java

Open
#568 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
243
Forks
171
Avg merge
30m
Merged PRs (30d)
4

Description

Hello,

I tried the example https://github.com/oracle/oci-java-sdk/blob/master/bmc-examples/src/main/java/CreateInstanceExample.java
with the latest SDK version and providing the arguments mentioned by the example. However the example fails with:

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" com.oracle.bmc.model.BmcException: Error returned by ListAvailabilityDomains operation in Identity service.(401, NotAuthenticated, false) The required information to complete authentication was not provided or was incorrect. (opc-request-id: C936D868CDD14E86ABD33B089FBE87D1/0477CC4974ED912CFA787CE7B4B46A00/1EC18D8155B178BAD7A5AD7E9566F2D7)
Timestamp: 2023-12-14T10:55:18.221Z
Client version: Oracle-JavaSDK/3.31.0
Request Endpoint: https://identity.us-phoenix-1.oci.oraclecloud.com/20160918/availabilityDomains?compartmentId=******************************************************
Troubleshooting Tips: See https://docs.oracle.com/en-us/iaas/Content/API/References/apierrors.htm#apierrors_401__401_notauthenticated for more information about resolving this error
Also see https://docs.oracle.com/iaas/api/#/en/identity/20160918/AvailabilityDomain/ListAvailabilityDomains for details on this operation's requirements.
To get more info on the failing request, you can enable debug level logs as mentioned in `Using SLF4J for Logging section` in https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/javasdkconfig.htm.
If you are unable to resolve this Identity issue, please contact Oracle support and provide them this full error message.
	at com.oracle.bmc.http.internal.ClientCall.lambda$checkError$18(ClientCall.java:816)
	at java.base/java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:934)
	at java.base/java.util.concurrent.CompletableFuture.uniHandleStage(CompletableFuture.java:950)
	at java.base/java.util.concurrent.CompletableFuture.handle(CompletableFuture.java:2372)
	at java.base/java.util.concurrent.CompletableFuture.handle(CompletableFuture.java:144)
	at com.oracle.bmc.http.internal.ClientCall.checkError(ClientCall.java:772)
	at com.oracle.bmc.http.internal.ClientCall.transformResponse(ClientCall.java:637)
	at com.oracle.bmc.http.internal.ClientCall.lambda$callAsyncImpl$24(ClientCall.java:1021)
	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
	at com.oracle.bmc.http.internal.SyncFutureWaiter$Waiter.waitAndWork(SyncFutureWaiter.java:63)
	at com.oracle.bmc.http.internal.SyncFutureWaiter.listenForResult(SyncFutureWaiter.java:32)
	at com.oracle.bmc.http.internal.ClientCall.callSync(ClientCall.java:1089)
	at com.oracle.bmc.identity.IdentityClient.listAvailabilityDomains(IdentityClient.java:2543)
	at org.example.Main.getAvailabilityDomains(Main.java:278)
	at org.example.Main.main(Main.java:179)

The key provided is for sure a valid one as I it has been obtained via OCI user interface and I tested it with another SDK. In the above stack trace I removed my compartmentID as that is sensitive information to publish.

Can you please provide a solution to this?

Thank you

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with bmc-examples/src/main/java/CreateInstanceExample.java and reproduce the failure using the arguments described in the example. Trace the authentication setup through the ListAvailabilityDomains call shown in the stack trace; done means the example authenticates successfully and proceeds without the reported 401 NotAuthenticated error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, authentication, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.