Hi,
I am trying to create a Vue app following the guid in the Developer Console.
I managed to install something and spin up vite. However, it seems that the FoundryClient is missing in the OSDK:
Am I doing something wrong? Are the some pitfalls when it comes to the genmeration of the OSDK? The OAuth2 client was created and everything.
I did not change any code so far…
Best,
Florian
ewitkon
January 31, 2025, 10:20pm
2
I am guessing this is an old template which needs to update.
add these to your package.json
"@osdk/client": "latest",
"@osdk/oauth": "latest",
and import respectively…
import { $ontologyRid } from "@<YOUR PACKAGE NAME>/sdk";
import { Client, createClient } from "@osdk/client";
import { createPublicOauthClient } from "@osdk/oauth";
export const url = import.meta.env.VITE_FOUNDRY_API_URL;
const clientId = import.meta.env.VITE_FOUNDRY_CLIENT_ID;
const redirectUrl = import.meta.env.VITE_FOUNDRY_REDIRECT_URL;
checkEnv(url, "VITE_FOUNDRY_API_URL");
checkEnv(clientId, "VITE_FOUNDRY_CLIENT_ID");
checkEnv(redirectUrl, "VITE_FOUNDRY_REDIRECT_URL");
function checkEnv(
value: string | undefined,
name: string,
): asserts value is string {
if (value == null) {
throw new Error(`Missing environment variable: ${name}`);
}
}
const scopes: string[] = [
"api:ontologies-read",
"api:ontologies-write",
];
export const auth = createPublicOauthClient(clientId, url, redirectUrl, true, undefined, window.location.toString(), scopes);
export const client: Client = createClient(url, $ontologyRid, auth);
Thank you for the fast response. I managed to get oauth working.
Let’s see how far i can come on my own, there seem to be multiple issues with this old template so that one cannot simply replace the auth and client as suggested.
system
Closed
April 1, 2025, 11:07pm
4
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.