-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
The Error
Error verifying token from Myinfo {
name: 'SyntaxError',
message: 'Unexpected token \u0005 in JSON at position 0',
stack: 'SyntaxError: Unexpected token \u0005 in JSON at position 0\n' +
' at JSON.parse (<anonymous>)\n' +
' at /Users/tamirshklaz/Documents/Programming/Strive/WhatsApp/community/node_modules/node-jose/lib/jws/verify.js:91:28\n' +
' at Array.map (<anonymous>)\n' +
' at JWSVerifier.value (/Users/tamirshklaz/Documents/Programming/Strive/WhatsApp/community/node_modules/node-jose/lib/jws/verify.js:88:25)\n' +
' at Object.<anonymous> (/Users/tamirshklaz/Documents/Programming/Strive/WhatsApp/community/node_modules/@govtechsg/singpass-myinfo-oidc-helper/dist/util/JweUtil.js:36:46)\n' +
' at Generator.next (<anonymous>)\n' +
' at fulfilled (/Users/tamirshklaz/Documents/Programming/Strive/WhatsApp/community/node_modules/@govtechsg/singpass-myinfo-oidc-helper/dist/util/JweUtil.js:5:58)\n' +
' at runMicrotasks (<anonymous>)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:97:5)'
}
My Environment
I'm using the latest version of NextJS with node v14
I'm setting up the Helper like this
import {MyInfo} from "@govtechsg/singpass-myinfo-oidc-helper";
const fs = require('fs');
let privateKey = fs.readFileSync("./ssl/stg-demoapp-client-privatekey-2018.pem","utf8")
let publicKey = fs.readFileSync("./ssl/staging_myinfo_public_cert.cer","utf8")
export const helper = new MyInfo.Helper({
clientID: "STG2-MYINFO-SELF-TEST",
environment: "sandbox",
singpassEserviceID: "STG2-MYINFO-SELF-TEST",
clientSecret: "44d953c796cccebcec9bdc826852857ab412fbe2",
keyToDecryptJWE: privateKey,
certToVerifyJWS: publicKey,
privateKeyToSignRequest: privateKey,
redirectUri: "http://localhost:3001/callback",
})
The error occurs when I call helper.getPerson()
import {helper} from "./utils";
export default async function getPerson(req, res) {
const code = req.query.code;
const token = await getToken(code)
// Error occurs here
const person = await helper.getPerson(`Bearer ${token.access_token}`, ["name","mobileno"])
console.log("PERSON",person)
res.status(200).json({person})
}
async function getToken(code: string) {
let token = await helper.getToken(code)
console.log("ACCESS TOKEN", token.access_token)
return token
}
Metadata
Metadata
Assignees
Labels
No labels