CORS error on Platform API SDK

Trying to get list of models in the library of my shape diver account.

  • Tried the below snippet from npm packages page with the actual values.
const client = create({clientId: "CLIENT_ID", baseUrl: "SHAPEDIVER_PLATFORM_API_ENDPOINT"});
await client.authorization.passwordGrant("USERNAME OR ACCESS KEY ID", "PASSWORD OR ACCESS KEY SECRET");

seeing the following CORS error

Thank you in advance!
Best regards,
Harsha

We currently do not support calling this API from a frontend web application (from a browser). You would need to make the call from a backend application.

Please explain your goal, such that we can come up with a solution.

The goal is to show all the models as a list to the user on browser.The idea from there is to render the model from the data obtained in the platform api response using Viewer API.

Ok understood. Are you implementing a full stack web application (frontend and backend)?

Yes we are implementing a full stack application. I have tried getting the models from backend and got the models in the response. But those were different from the models in our library. They were random models. Is it because of the client id ? If it is because of the client id can you please guide on where to find the client id?

Thanks and regards

Probably you were not filtering the models by your user_id and therefore also saw public models. In order to determine how to choose the request body, you can use the browser developer tools and observe some model query requests when using the platform.

@snabela Thank you so much that resolved the issue.

1 Like