Skip to content
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

Using SDK with Next.js (Authentication) #277

Open
ksi9302 opened this issue Mar 26, 2024 · 1 comment
Open

Using SDK with Next.js (Authentication) #277

ksi9302 opened this issue Mar 26, 2024 · 1 comment

Comments

@ksi9302
Copy link

ksi9302 commented Mar 26, 2024

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,
});
@JoshuaWR
Copy link
Member

Hi @ksi9302. Could you share what problem exactly you are having with config files? Here are 2 good pieces of documentation that should help you get started with them:
https://docs.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm
https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdkgettingstarted.htm#configuring
Small note, you do not need to pass in configProfile or configurationFilePath to ConfigFileAuthenticationDetailsProvider if you use the default config path of ~/.oci/config and default profile name of [DEFAULT]. Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants