While trying to use @okta/okta-sdk-nodejs i get an error for invalid character in JSON

i am using the @okta/okta-sdk-nodejs , set the client according to documentation :
const client = new okta.Client({
orgUrl: ‘’,
authorizationMode: ‘PrivateKey’,
clientId: '. ',
scopes: [‘okta.users.read’],
privateKey: key, // the key is a JSON as a string that was copied according to the guide, currently in another file and exported as string
keyId: ‘<my kid from the app integration API service general tab’,

when running any api , for example :
const user = await client.userApi.getUser({ userId: ‘00u7j1z1z1Z2Z2Z2Z2Z2’ })

i get the following error :
“invalid json response body at /error/404?fromURI=%2Foauth2%2Fv1%2Ftoken reason: Unexpected token ‘<’, "<!DOCTYPE "… is not valid JSON”

I could not find any ‘<’ sign …

my key file looks like :

export const key = { "d": "<some-string>", "p": "<some-string>", "q": "<some-string>", "dp": "<some-string>", "dq": "<some-string>", "qi": "<some-string>", "kty": "RSA", "e": "<some-string>", "kid": "my KID", "n": "<some-string>" }

can you please help to understand what may be the issue ?

What’s your specific goal in signing your own private key tokens using this SDK? Typically, it’s best to utilize built-in directives whenever possible. Have you explored those options yet?

You would need to explain a bit more of the requirements? The Key format is throwing this error.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.