Skip to content

Using SDK with Next.js (Authentication) #277

Open
@ksi9302

Description

@ksi9302

Hi Team,

Thanks for your effort in enabling the oci in javascript.

I've come across a slight issue when trying to implement the SDK in my Next.js project (in server action).
I just can't get my head around on how to configure the credentials using the config files.. which I assume it has something to do with path / incompatibility.

At the moment I'm using SimpleAUthenticationDetailsProvider as the alternative, but if possible, I'd rather use the config files as I believe it to be safer option.

For anyone wondering my current implementation, see below.

"use server";

import * as objectstorage from "oci-objectstorage";
import * as common from "oci-common"; 
// do not import common from "oci-common"

const tenancy: string = process.env.ORACLE_TENANCY as string;
const user: string = process.env.ORACLE_USER as string;
const fingerprint: string = process.env.ORACLE_FINGERPRINT as string;
// const passphrase: string | null = null; // optional parameter
const privateKey: string = process.env.ORACLE_PEM as string;
const region: common.Region = common.Region.AP_MELBOURNE_1; // Change to appropriate region

const provider = new common.SimpleAuthenticationDetailsProvider(
  tenancy,
  user,
  fingerprint,
  privateKey,
  null,
  region
);

// using the client with provider
const client = new objectstorage.ObjectStorageClient({
      authenticationDetailsProvider: provider,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions