Has anybody seen this error? API input error: Plea...
# support-questions-legacy
d
Has anybody seen this error? API input error: Please make sure to pass valid URL query params 2023-02-25T22:28:00.818Z com.supertokens {t: "2023-02-25T22:28:00.818Z", message: "errorHandler: Started", file: "/Users/dave/Code/node_modules/supertokens-node/lib/build/supertokens.js:321:26" sdkVer: "13.0.2"} 2023-02-25T22:28:00.818Z com.supertokens {t: "2023-02-25T22:28:00.818Z", message: "errorHandler: Error is from SuperTokens recipe. Message: API input error: Please make sure to pass valid URL query params", file: "/Users/dave/Code/node_modules/supertokens-node/lib/build/supertokens.js:323:30" sdkVer: "13.0.2"} 2023-02-25T22:28:00.818Z com.supertokens {t: "2023-02-25T22:28:00.818Z", message: "errorHandler: Sending 400 status code response", file: "/Users/dave/Code/node_modules/supertokens-node/lib/build/supertokens.js:325:34" sdkVer: "13.0.2"} 2023-02-25T22:28:00.819Z com.supertokens {t: "2023-02-25T22:28:00.818Z", message: "Sending response to client with status code: 400", file: "/Users/dave/Code/node_modules/supertokens-node/lib/build/utils.js:133:14" sdkVer: "13.0.2"} I'm getting it when trying to implement Sign In with Apple. I'm POSTing to /api/auth/callback/apple a
state
and a
code
value Everything seems like it should work.
r
are you manually posting to that path or is apple doing it? If you are manually posting, can i see how?
d
it's being posted by Apple
r
can you show your nextjs backend api code which handles this request?
(the api function that uses supertokens middleware)
and also the supertokens.init on the backend
d
Copy code
import { superTokensNextWrapper } from "supertokens-node/nextjs"
import { middleware } from "supertokens-node/framework/express"
import supertokens from "supertokens-node"
import { backendConfig } from "../../../config/backendConfig"
import NextCors from "nextjs-cors"
import { websiteDomain } from "../../../config/appInfo"

supertokens.init(backendConfig())

export default async function superTokens(req, res) {
    // NOTE: We need CORS only if we are querying the APIs from a different origin
    await NextCors(req, res, {
        methods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"],
        origin: websiteDomain,
        credentials: true,
        allowedHeaders: ["content-type", ...supertokens.getAllCORSHeaders()]
    })

    await superTokensNextWrapper(
        async (next) => {
            // This is needed for production deployments with Vercel
            res.setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate")
            await middleware()(req, res, next)
        },
        req,
        res
    )
    if (!res.writableEnded) {
        res.status(404).send("Not found")
    }
}
r
can you remove the
NextCors
and also the
res.setHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate")
line and try again?
d
didn't help. If interested, you can inspect the client-side bits at https://qa.dvcforless.com/auth
Nothing too exciting, though
r
this may be a bug in our library. Can you please open an issue about this on our github, and we will check it out in the coming week.
hey @davido_k so this is indeed a bug in our lib. We will fix it asap. You can follow this issue to know the status: https://github.com/supertokens/supertokens-node/issues/496
d
thanks!
r
hey @davido_k we have released a new version of the node SDK with the fix.
d
@rp_st I finally got back to this but am receiving a new error in the thirdPartySignInUpPOST method.
Copy code
2023-03-05T04:30:32.767Z com.supertokens {t: "2023-03-05T04:30:32.767Z", message: "middleware: Request being handled by recipe. ID is: /signinup", file: "/Users/dave/Code/node_modules/supertokens-node/lib/build/supertokens.js:280:30" sdkVer: "13.1.2"}

2023-03-05T04:30:33.633Z com.supertokens {t: "2023-03-05T04:30:33.633Z", message: "errorHandler: Started", file: "/Users/dave/Code/node_modules/supertokens-node/lib/build/supertokens.js:323:26" sdkVer: "13.1.2"}

error - Error: SuperTokens core threw an error for a POST request to path: '/recipe/signinup' with status code: 400 and message: Field name 'id' is invalid in JSON input

    at Querier.<anonymous> (/Users/dave/Code/node_modules/supertokens-node/lib/build/querier.js:259:31)
    at Generator.throw (<anonymous>)
    at rejected (/Users/dave/Code/node_modules/supertokens-node/lib/build/querier.js:22:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  page: '/api/auth/[[...path]]'
}
I have a console.write right after this that isn't getting hit
Copy code
let response = await originalImplementation.thirdPartySignInUpPOST(input)
                                console.log("POST - Original complete")
r
Have you give Any custom scope?
d
no custom scope in the backendConfig. I'll double-check the config on the developer portal
r
can you try with our dev keys and check if that works?
d
hmm, that does work
r
hmmm
whats the configured redirect_uri on the apple dashboard?
d
the return url? I have a few /api/auth/callback/apple and /auth/callback/apple are both in there. Or a different setting?
apple is posting to /api/auth/callback/apple then I send a GET auth/callback/apple?state=f7ac235dxxxxxx...&code=c92 then a post to /api/auth/signinup that returns the 500 from the error above
r
right. So the redirect uri seems fine
r
hmm. @sattvikc can help here sometime tomorrow
d
thanks
I found this and it's a pretty good lead of what's going on. Could be a dev artifact or could be a scenario that needs to be covered: https://developer.apple.com/forums/thread/132223
r
Thanks. @sattvikc will have a look tomorrow.
s
hi @davido_k could you share what's being posted (payload) to the signinup API by inspecting the network tab in the browser ?
d
{"code":"c942ed63083c644fba342b6e6e520ab61.0.mwrq.QS54Cccps4yvKDM6ZOASoQ","thirdPartyId":"apple","redirectURI":"https://0ad1-135-134-205-237.ngrok.io/auth/callback/apple"}
s
mmm okay, give me a min. I'll share a snippet for you to try
Copy code
ts
function Apple(config: any) : ThirdParty.TypeProvider {
    const appleProvider = ThirdParty.Apple(config);

    return {
        ...appleProvider,
        get: function(redirectURI: string | undefined, authCodeResponse: string | undefined, userContext: any) : TypeProviderGetResponse {
            console.log("GET: ", redirectURI, authCodeResponse, userContext);
            const getResponse = appleProvider.get(redirectURI, authCodeResponse, userContext);

            return {
                ...getResponse,
                getProfileInfo: async function(authCodeResponse, userContext) {
                    console.log("GET PROFILE INFO: ", authCodeResponse);
                    const result = await getResponse.getProfileInfo(authCodeResponse, userContext);
                    console.log('PROFILE RESULT', result);
                    return result;
                }
            }
        }
    }
}
can you try this apple provider and help me with the console logs? on the backend
d
seems to be working now. My console outputs are returning a valid email object as well. I don't think I changed anything on the Apple developer portal. `
s
mmm okay cool. let me know if you face any issues again
82 Views