https://supertokens.com/ logo
e

EdwinN1337

07/14/2022, 7:40 AM
hey, we're trying to add apple as a third party provider (since apple don't allow social login if you don't have apple as option) when we add apple as provider we get the famous
[object Object]
error, can't figure out why
r

rp

07/14/2022, 7:41 AM
Hey! Where is this error coming from? Frontend or backend?
And how have you added the provider?
e

EdwinN1337

07/14/2022, 7:42 AM
Hey! 🙂
it's comming from the backend (api route)
r

rp

07/14/2022, 7:42 AM
RIght, and from which API call? The /signinup one?
e

EdwinN1337

07/14/2022, 7:42 AM
(when adding Apple as provider, with the right keys we assume, it errors out)
get authorisation url
r

rp

07/14/2022, 7:43 AM
What input are you giving to that?
e

EdwinN1337

07/14/2022, 7:46 AM
When I comment out apple, it just works (giving me feedback),
r

rp

07/14/2022, 7:46 AM
huh.. did you rebuild your app / clear cache?
e

EdwinN1337

07/14/2022, 7:48 AM
yeah we did, trying to figure out how to json.stringify the error message
maybe wrong keys, not sure
we are recreating the keys again
r

rp

07/14/2022, 7:53 AM
hmm. Okay
e

EdwinN1337

07/14/2022, 7:55 AM
we recreated all keys, weird
still [object Object]
r

rp

07/14/2022, 7:55 AM
same error message from postman?
e

EdwinN1337

07/14/2022, 7:56 AM
postman gives back 500, html page
r

rp

07/14/2022, 7:56 AM
html page.. thats odd. We don't send any HTML reply
probably the default reply from the framework you are using
e

EdwinN1337

07/14/2022, 7:56 AM
nextjs, guess so
guess the error isnt catch somewhere
r

rp

07/14/2022, 7:56 AM
can you catch that error in your framework and do
console.dir(error)
You can add a try catch around the whole middleware part in the auth API
and print the error there
e

EdwinN1337

07/14/2022, 7:57 AM
we did
the error didnt come in the catch block
thats the weird part
Copy code
js
  try {
    await superTokensNextWrapper(
      async (next) => {
        await middleware()(req, res, next)
      },
      req,
      res,
    )
    if (!res.writableEnded) {
      res.status(404).send('Not found')
    }
  } catch (err) {
    console.dir(err)
ca
r

rp

07/14/2022, 7:59 AM
hmmm
Is the error happening when you call supertokens.init?
Cause if you give invalid apple keys, the supertokens.init will throw an error
e

EdwinN1337

07/14/2022, 8:01 AM
guess it's comming from the init,
r

rp

07/14/2022, 8:02 AM
right yea. That means the keys provided to the apple config are not valid
e

EdwinN1337

07/14/2022, 8:02 AM
Copy code
js

supertokens.init({
  ...backendConfig(),
})
export default async function superTokens(
  req: NextApiRequest & Request,
  res: NextApiResponse & Response,
) {
  console.log('hello?')
hello doesnt get consoled 😉 so we can assume its from the init hehe
right?
ye weird, we just recreated the keys 😮
r

rp

07/14/2022, 8:03 AM
Yea.. maybe add a try / catch around
Copy code
supertokens.init({
  ...backendConfig(),
})
And see the error message?
e

EdwinN1337

07/14/2022, 8:05 AM
ah thought the err would appear in the other try/catch my bad
shop-web:dev: ThirdPartyError { shop-web:dev: type: 'BAD_INPUT_ERROR', shop-web:dev: message: 'error:0909006C:PEM routines:get_name:no start line', shop-web:dev: payload: undefined, shop-web:dev: errMagic: 'ndskajfasndlfkj435234krjdsa', shop-web:dev: fromRecipe: 'thirdparty' shop-web:dev: } shop-web:dev: hello? shop-web:dev: error - Error: Initialisation not done. Did you forget to call the SuperTokens.init function?
r

rp

07/14/2022, 8:05 AM
So this means the init did not completed -> error from apple most likelty
e

EdwinN1337

07/14/2022, 8:06 AM
so most likely the keys
r

rp

07/14/2022, 8:06 AM
yes
e

EdwinN1337

07/14/2022, 8:06 AM
will try to recreate it again 😦
r

rp

07/14/2022, 8:06 AM
try using the dev keys we give -> do you run into the same error?
If not, then it's 100% the keys issue. Else something else
e

EdwinN1337

07/14/2022, 8:08 AM
i couldnt find the dev keys, the docs are changed right? 😉
r

rp

07/14/2022, 8:09 AM
it's there in the docs (quick setup > backend). But here they are:
Copy code
Apple({
                        clientId: "4398792-io.supertokens.example.service",
                        clientSecret: {
                            keyId: "7M48Y4RYDL",
                            privateKey:
                                "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----",
                            teamId: "YWQCXGJRJL",
                        },
                    }),
e

EdwinN1337

07/14/2022, 8:11 AM
hehe, ok its the keys 😉
we're probably doing sometghing wrong, will figure it out
thanks!@
r

rp

07/14/2022, 8:12 AM
cool! happy to help.
e

EdwinN1337

07/14/2022, 8:38 AM
ah, my misstake i forgot to add
/n
in the private key
in case someone else has this problem 😉 let them check the privateKey
r

rp

07/14/2022, 8:39 AM
right! cool!
4 Views