https://supertokens.com/docs/thirdpartyemailpasswo...
# support-questions-legacy
p
https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/deduplication/implementing-deduplication
Copy code
ts
     thirdPartySignInUpPOST: async (input) => {
              try {
                await originalImplementation.thirdPartySignInUpPOST!(input)
              }
              catch (err: any) {
                if (err.message === 'Cannot sign up as email already exists') {
                  // this error was thrown from our function override above.
                  // so we send a useful message to the user
                  return {
                    status: 'GENERAL_ERROR',
                    message: 'Seems like you already have an account with another method. Please use that instead.',
                  }
                }
                throw err
              }
r
hey @productdevbook it seems to be an issue with how you may have configured the github provider.
@sattvikc can help here
s
just a min, taking a look
can i see your github init ?
p
Copy code
ts

   recipeList: [
      ThirdPartyEmailPassword.init({
        providers: [
          Github({
            clientId: env.github.appId,
            clientSecret: env.github.privateKey,
          }),
        ],
but login client and supertoken token etc coming
s
is the privateKey same as clientSecret provided by github ?
p
yes
but dont used
How can I login even though it gives an error?
s
can you check if the env is set correctly ?
p
yes same code
s
it worked earlier?
p
It still works, I'm officially logging in, but that error always comes
s
the 401 error typically means the token was not acquired on the token API. could you replicate that request on the postman ?
p
Against the error, your system registers the user and the token is returned. interested
s
strange! just to be sure, which error are you referring to ?
if the user API does not pass, the user will not be added to the core
p
no your system added
all delete db and reset github user
and after login same
and return token your system and login client
super token db
this error backend code.
s
do u mean the backend has an issue with the API call and still the login works as expected?
p
yes
s
is the returned email correct as well?
p
yes
s
could you share your complete supertokens init? maybe I can try to reproduce and see
p
my backend code
s
let me know your frontend and backend SDK versions as well
p
"supertokens-web-js": "^0.3.0", "supertokens-node": "^12.1.2",
s
okay, let me get back to u in a while
p
await originalImplementation.thirdPartySignInUpPOST!(input)
iam delete and fixed https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/deduplication/implementing-deduplication but your added
s
not sure I understand that correctly, what did you delete?
p
I get an error when I add the code
r
You can't delete
await originalImplementation.thirdPartySignInUpPOST!(input)
. if that's not there, then it won't actually attempt to login the user at all.
ok so the problem is that you are calling
await originalImplementation.thirdPartySignInUpPOST!(input)
twice..
that will, obviously, not work
p
According to your docs I have added those codes but it is causing the error
r
If you see in our docs, we call
await originalImplementation.thirdPartySignInUpPOST
just once in the override
but you are calling it twice.
So the second time is failing.
which is expected
This is the code in the file you sent above:
Copy code
thirdPartySignInUpPOST: async (input) => {
              try {
                await originalImplementation.thirdPartySignInUpPOST!(input)

                if (!originalImplementation.thirdPartySignInUpPOST)
                  throw new Error('thirdPartySignInUpPOST is not available')

                const response = await originalImplementation.thirdPartySignInUpPOST(input)

                if (response.status === 'OK') {
                  const externalUserId = response.user.thirdParty
                    ? `${response.user.thirdParty.id}|${response.user.thirdParty.userId}`
                    : null

                  await storage.userRepo.ensureUserExists({
                    superTokensUserId: response.user.id,
                    email: response.user.email,
                    externalAuthUserId: externalUserId || undefined,
                  })
                }

                return response
              }
And as you can see, you are calling
await originalImplementation.thirdPartySignInUpPOST!(input)
at the start of the funciton, and then
const response = await originalImplementation.thirdPartySignInUpPOST(input)
again.
So your override code is just wrong.
p
Copy code
ts

   try {
                const response = await originalImplementation.thirdPartySignInUpPOST!(input)

                if (!originalImplementation.thirdPartySignInUpPOST)
                  throw new Error('thirdPartySignInUpPOST is not available')

                if (response.status === 'OK') {
                  const externalUserId = response.user.thirdParty
                    ? `${response.user.thirdParty.id}|${response.user.thirdParty.userId}`
                    : null

                  await storage.userRepo.ensureUserExists({
                    superTokensUserId: response.user.id,
                    email: response.user.email,
                    externalAuthUserId: externalUserId || undefined,
                  })
                }

                return response
              }
thats true ?
r
whats before the
try
line?
p
Copy code
ts

      thirdPartySignInUpPOST: async (input) => {
              try {
                const response = await originalImplementation.thirdPartySignInUpPOST!(input)

                if (!originalImplementation.thirdPartySignInUpPOST)
                  throw new Error('thirdPartySignInUpPOST is not available')

                if (response.status === 'OK') {
                  const externalUserId = response.user.thirdParty
                    ? `${response.user.thirdParty.id}|${response.user.thirdParty.userId}`
                    : null

                  await storage.userRepo.ensureUserExists({
                    superTokensUserId: response.user.id,
                    email: response.user.email,
                    externalAuthUserId: externalUserId || undefined,
                  })
                }

                return response
              }
              catch (err: any) {
                if (err.message === 'Cannot sign up as email already exists') {
                  // this error was thrown from our function override above.
                  // so we send a useful message to the user
                  return {
                    status: 'GENERAL_ERROR',
                    message: 'Seems like you already have an account with another method. Please use that instead.',
                  }
                }
                throw err
              }
            },
r
yea. this seems fine
if this also doens't work, then please check your github credentials,.
p
okay thank you now fixed
and email signup return error 🔥
r
nice
p
I am working on a project of mine. I will sponsor you once I go live and start making money.
Thanks for all the help
4 Views