Skip to content

Unauthorized error on identitydomains #310

Open
@farisdurrani

Description

@farisdurrani

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,

import * as common from "oci-common";
import { IdentityDomainsClient, responses } from "oci-identitydomains";

const DOMAIN_ENDPOINT =
  "https://idcs-721677994de24d38836f554cc565a9d5.identity.oraclecloud.com:443";
const provider: common.ConfigFileAuthenticationDetailsProvider =
  new common.ConfigFileAuthenticationDetailsProvider(
    "~/.oci/config",
    "fdurrani"
  );

(async () => {
  const identityDomainsClient = new IdentityDomainsClient({
    authenticationDetailsProvider: provider,
  });
  identityDomainsClient.endpoint = DOMAIN_ENDPOINT;

  const usersList: responses.ListUsersResponse =
    await identityDomainsClient.listUsers({});

  console.log(usersList);
})();

running this file using node returns this error:

test git:(dev) ✗ ts-node test2.ts
Request cannot be retried. Not Retrying. Exception occurred : Error: Unauthorized
OciError: Unauthorized
    at Object.handleErrorResponse (/Users/fdurrani/LocalGitHub/policy-analyzer/lib/helper.ts:66:12)
    at GenericRetrier.<anonymous> (/Users/fdurrani/LocalGitHub/policy-analyzer/lib/retrier.ts:226:31)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/fdurrani/LocalGitHub/policy-analyzer/test/node_modules/oci-common/lib/retrier.js:9:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  statusCode: 401,
  serviceCode: 'None',
  opcRequestId: '29F2A911532C-11EF-88E5-FF736DD40B23/pU9iq01W240000000',
  targetService: 'IdentityDomains',
  operationName: 'listUsers',
  timestamp: '2024-08-05T13:11:01.921Z',
  requestEndpoint: 'GET https://idcs-721677994de24d38836f554cc565a9d5.identity.oraclecloud.com:443/admin/v1/Users',
  clientVersion: 'Oracle-TypeScriptSDK/2.90.0-1722272724',
  loggingTips: 'To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdkconcepts.htm#typescriptsdkconcepts_topic_Logging for ways to log the request/response details.',
  troubleshootingTips: 'See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_401__401_none for more information about resolving this error If you are unable to resolve this IdentityDomains issue, please contact Oracle support and provide them this full error message.'
}
➜  test git:(dev) ✗ 

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

Screenshot 2024-08-05 at 09 15 36

Relevant software versions:

  "dependencies": {
    "oci-common": "^2.90.0-1722272724",
    "oci-identitydomains": "^2.90.0-1722272724"
  }

OS: MacOS 14.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    SDKIssue pertains to the SDK itself and not specific to any service

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions