-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Package: kontist@0.52.12
I'm getting a timeout when trying to fetch a token from an authorization code using the JS SDK. It looks like the specifics of the API changed without them being reflected in the SDK?
The Error
Error fetching token: Error
at onRequestError (/Users/leon/code/invoice-tool/node_modules/popsicle-transport-http/dist/index.js:405:31)
at emitError (node:events:43:23)
at emitErrorNT (internal:streams/destroy:88:12)
at emitErrorCloseNT (internal:streams/destroy:69:14)
at processTicksAndRejections (native:7:39) {
request: Request {
'$rawBody': Symbol(bodyUsed),
url: 'https://api.kontist.com/api/oauth/token',
method: 'POST',
signal: Signal { _: [], '$': [Object: null prototype], aborted: false },
headers: Headers { object: [Object: null prototype] },
trailer: Promise { [Headers] }
},
code: 'EUNAVAILABLE',
[cause]: Error: Stream closed with error code NGHTTP2_PROTOCOL_ERROR
at unknown
at emitStreamErrorNT (node:http2:1791:47)
at processTicksAndRejections (native:7:39)
}
The following exception was the direct cause of the above exception:
Error: Stream closed with error code NGHTTP2_PROTOCOL_ERROR
at unknown
at emitStreamErrorNT (node:http2:1791:47)
at processTicksAndRejections (native:7:39)
The Code
import { Client } from "kontist";
const kontist = new Client({
clientId: "***",
scopes: ["transactions"],
redirectUri: "http://localhost:3000/auth/callback",
state: crypto.randomUUID(),
});
Bun.serve({
port: 3000,
routes: {
"/": async (request) => {
console.log(request.method, request.url);
return Response.redirect(await kontist.auth.tokenManager.getAuthUri());
},
"/auth/callback": async (request) => {
console.log(request.method, request.url);
console.log("Callback received. Fetching token...");
try {
const token = await kontist.auth.tokenManager.fetchToken(request.url);
console.log(token);
} catch (error) {
console.error("Error fetching token:", error);
return new Response("Error fetching token", { status: 500 });
}
return new Response("😎");
},
},
});
console.log("Server is running on http://localhost:3000");Metadata
Metadata
Assignees
Labels
No labels