Question

Authentication Issue: While trying to use 3D models through cognite/reveal

  • 13 February 2024
  • 0 replies
  • 38 views


I have solved the BufferGeometry issue was present earlier, apparently the react-app-wired was not the latest which is why the override was not working.

import React, { useEffect } from "react"
import { Cognite3DViewer } from "@cognite/reveal"
import { CogniteClient, CogniteAuthentication } from "@cognite/sdk"

import { getToken } from "../../utils/MsGraphApiCall"

import "./Models.css"

function Models() {
const appId = "KPI-Dev"
const project = "celanese-dev"
const clientId = "my-client-d"
const tenantId = "my-tenant-id"
const cluster = "az-eastus-1"
const modelId = 7575155737800092
const revisionId = 3624517118008353

async function start() {
await client.authenticate(clientId, tenantId, cluster)

const viewer = new Cognite3DViewer({
sdk: client,
domElement: document.querySelector("#your-element-for-viewer"),
})
viewer.addModel({ modelId: modelId, revisionId: revisionId })
}

const legacyInstance = new CogniteAuthentication({
project,
})

// getToken()

const getToken = async () => {
await legacyInstance.handleLoginRedirect()
let token = await legacyInstance.getCDFToken()
console.log("Token: ", token)
if (token) {
console.log("Token: ", token.accessToken)
return token.accessToken
}
token = await legacyInstance.login({ onAuthenticate: "REDIRECT" })
if (token) {
return token.accessToken
}
throw new Error("authentication error")
}

console.log("TOken: ", getToken())

const client = new CogniteClient({
appId,
project,
getToken,
})

useEffect(() => {
start()
}, []) // Empty dependency array to ensure it runs only once after mounting

return <div id='your-element-for-viewer'>Models</div>
}

export default Models

But, now when I try to connect to cognite/reveal using the project, appId and all other details. The server responds with 

This api.cognitedata.com page can’t be found

 

I’m attaching the component’s source code from where I’m trying to connect to cognite. And I would appreciate if I can be enlightened with a way to work this out.

A help would be highly appreciated.

 

Image attached below for reference.

Error Image

 

Thank you

Regards, 
Hariharan


0 replies

Be the first to reply!

Reply