oracle / oracle/oci-typescript-sdk
NotAuthenticated with the SDK on retreiving namespaces
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 100
- Forks
- 64
- Avg merge
- 14m
- Merged PRs (30d)
- 5
Description
Environment
Host: Linux instance-20230814-xxxx 5.15.0-1039-oracle #45-Ubuntu SMP Thu Jul 13 19:41:22 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
Bun: 1.1.7
oci-sdk: 2.101.0
Description
I'm experiencing a NotAuthenticated (401) error whenever I want to retreive namespaces with the Typescript SDK.
What I checked
-
Everything suggested in here : https://docs.oracle.com/en-us/iaas/Content/API/References/apierrors.htm#apierrors_401__401_notauthenticated
- "Verify your
private_key_pathis pointing to your private key and not the corresponding public key"
Not sure if this part of the documentation hasn't been updated but I only have akey_pathin my conf, it doesn't work withprivate_key_path
- "Verify your
-
IAM Permission/Policies are correct
- I've created a group 'App' which in my user is, the same user I've created the API key for, the same user I've put the OCID in the conf file
- I've added this policy :
Allow group 'App' to read objectstorage-namespaces in tenancy
-
~/.oci/configfile is correct -
Private key is correct
-
With all of the above: it works perfectly fine with the CLI using the command
oci os ns getwith the same config file and profile I'm trying to use with the sdk -
Loggin the
ObjectStorageClientobject shows me that the configuration file has been loaded correctly (I can see my OCIDs, my private key, etc.)
Configuration file
[DEFAULT]
user=ocid1.user.oc1..aaaaa...
fingerprint=63:5d:fd:...
tenancy=ocid1.tenancy.oc1..aaa....
region=eu-paris-1
key_file=~/.ssh/oracle/oci_api_key.pem
Code
import common from 'oci-common';
import objectstorage from 'oci-objectstorage';
const provider = new common.ConfigFileAuthenticationDetailsProvider();
const client = new objectstorage.ObjectStorageClient({
authenticationDetailsProvider: provider
});
export const getNamespace = async (): Promise<string | undefined> => {
try {
const namespace = await client.getNamespace({}).then((res: objectstorage.responses.GetNamespaceResponse) => res.value);
return namespace;
} catch (error: any) {
console.error("Err code:", error.statusCode);
console.error("Err message:", error.message);
console.error("Err stack:", error.stack);
return '';
}
}
Error stack
Err code: 401
Err message: Get namespace is limited to authenticated users
Err stack: Error: Get namespace is limited to authenticated users
at new OciError (/home/ubuntu/project/core/node_modules/oci-common/lib/error.js:12:13)
at handleErrorResponse (/home/ubuntu/project/core/node_modules/oci-common/lib/helper.js:35:28)
at <anonymous> (/home/ubuntu/project/core/node_modules/oci-common/lib/retrier.js:145:92)
at fulfilled (/home/ubuntu/project/core/node_modules/oci-common/lib/retrier.js:8:73)
at processTicksAndRejections (:12:39)
Note
Even when I hardcode the namespace in my code to retreive buckets, I get an error (404 this time), even though I filled in the right information, and of course this too works fine with the CLI.
Did I obviously missed a thing somewhere? Thanks for your help. 🙏
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ConfigFileAuthenticationDetailsProvider and ObjectStorageClient calls shown in the issue, then compare their behavior with the working oci os ns get CLI command using the same profile. Trace the authentication request through the reported oci-common error path. Done means namespace and bucket retrieval authenticate and return the expected results with the documented configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100