-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unauthorized error on identitydomains #310
Comments
Surprisingly, using a signed HttpRequest to the raw URI results in an Unauthorized error as well on TypeScript See code and resultimport * as promise from "es6-promise";
import "isomorphic-fetch";
import { DefaultRequestSigner, HttpRequest } from "oci-common";
import { common } from "oci-sdk";
promise.polyfill();
const OCI_CONFIG_FILE = "~/.oci/config";
const OCI_PROFILE = "fdurrani";
const CONFIG = new common.ConfigFileAuthenticationDetailsProvider(
OCI_CONFIG_FILE,
OCI_PROFILE
);
async function compileAllUsers() {
// 1. Create Request Signing instance
const signer = new DefaultRequestSigner(CONFIG);
// 2. Create HttpRequest to be signed
const httpRequest: HttpRequest = {
uri: `https://idcs-721677994de24d38836f554cc565a9d5.identity.oraclecloud.com:443/admin/v1/Users`,
headers: new Headers(),
method: "GET",
};
// 3. sign request
await signer.signHttpRequest(httpRequest);
// 4. Make the call
const response = await fetch(
new Request(httpRequest.uri, {
method: httpRequest.method,
headers: httpRequest.headers,
body: httpRequest.body,
})
);
// 5. Print response
console.log(await response.json());
}
compileAllUsers(); ➜ test git:(dev) ✗ ts-node test2.ts
{
schemas: [ 'urn:ietf:params:scim:api:messages:2.0:Error' ],
detail: 'The request failed: HTTP 401 Unauthorized.',
status: '401'
} |
hi @farisdurrani, are you using Bun or Deno? I had similar issues until I've came back to the original NodeJS. |
No, I am using the original NodeJS. As in, Node v20.11.0 and NPM v10.4.0 |
Hi @farisdurrani what version of typescript SDK are you using ? Are you able to make API call using raw request signer ? |
No, I was not able to make an API call using the raw request signer. See: #310 (comment). Again, it is important to note using the CLI, both on the identity-domains CLI and raw request API, works fine. |
@farisdurrani I meant to ask the version of OCI typescript SDK (oci-sdk) |
Yes, I've put that info at the end of my original post |
I am getting a 401 Unauthorized error when using the
identitydomains
module even when the CLI on the same API URL returns a valid result and all other modules work fine. I am a tenancy administrator. This issue repeats on several tenancies.Given this TypeScript script adapted from the official example,
running this file using node returns this error:
Calling the same API URL using the CLI returns the result as normal:
➜ ~ oci raw-request --http-method GET --target-uri https://idcs-721677994de24d38836f554cc565a9d5.identity.oraclecloud.com:443/admin/v1/Users --profile fdurrani
Relevant software versions:
OS: MacOS 14.6
The text was updated successfully, but these errors were encountered: