builder
builder copied to clipboard
Admin SDK not connecting–"Private Key is required"
Describe the bug
When I try to initialize the Admin SDK and run a basic query that works in the GraphQL explorer, with the same private key used there, I get an error that "Private Key is required". I've tried using an env var as well as hard-coding the private key and neither work. I've also tried initializing the Admin SDK inside a Next.js getStaticProps
function and outside (like how the Builder instance is instantiated).
To Reproduce Steps to reproduce the behavior (follow the tutorial but here's what I did):
- Install the admin SDK with
npm install --save @builder.io/admin-sdk
- Import it with
import { createAdminApiClient } from '@builder.io/admin-sdk';
. - Instantiate it with
const adminSdk = createAdminApiClient(process.env.BUILDERIO_PRIVATE_API_KEY);
, either ingetStaticPaths
or outside of it. confirm that theBUILDERIO_PRIVATE_API_KEY
env var is defined (or hard code your private API key from your space that works with the GraphQL explorer). - Try a simple query that works in the GraphQL explorer such as the following:
const res = await adminSdk.query({
models: {
name: true
}
});
Expected behavior
It should work just like the example code and reflect what's to be expected from the GraphQL explorer. I had an easier time connecting to the Admin SDK GraphQL using fetch
than I did with the SDK.
Error log
{
errors: [
{
message: 'Private Key is required',
locations: [Array],
path: [Array],
extensions: [Object]
}
],
data: { models: null },
extensions: {
tracing: {
version: 1,
startTime: '2022-12-06T23:11:23.282Z',
endTime: '2022-12-06T23:11:23.363Z',
duration: 80553819,
execution: [Object]
}
}
}
Hi @davidrhoderick, this error happens when you are not passing a valid private key value, please double-check the value you have in your environment for process.env.BUILDERIO_PRIVATE_API_KEY
@davidrhoderick Are you still experiencing this issue? I am closing this issue due to staleness, but please feel free to reopen if you still need help.
Hey @samijaber , yea I don't work with Builder anymore so you can close this