mogalmahesh
05/06/2022, 2:06 PMrp
05/06/2022, 2:07 PMmogalmahesh
05/06/2022, 2:07 PMconst appInfo = {
// learn more about this on https://supertokens.com/docs/thirdpartyemailpassword/appinfo
appName: "Super token test",
apiDomain: "http://localhost:4000",
websiteDomain: "http://localhost:3000",
apiBasePath: "/auth",
websiteBasePath: "/auth"
}
export const frontendConfig = () => {
return {
appInfo,
recipeList: [
ThirdPartyEmailPasswordReact.init({
useShadowDom: false,
signInAndUpFeature: {
signUpForm: {
termsOfServiceLink: "https://example.com/terms-of-service",
privacyPolicyLink: "https://example.com/privacy-policy"
},
providers: [
ThirdPartyEmailPasswordReact.Google.init(),
],
},
}),
SessionReact.init(),
],
}
}
framework: 'express',
// isInServerlessEnv: true,
supertokens: {
// try.supertokens.com is for demo purposes. Replace this with the address of your core instance (sign up on supertokens.com), or self host a core.
connectionURI:
'#URL',
apiKey: '#API_KEY',
},
appInfo: {
// learn more about this on https://supertokens.com/docs/thirdpartyemailpassword/appinfo
appName: 'Super token test',
apiDomain: 'http://localhost:4000',
websiteDomain: 'http://localhost:3000',
apiBasePath: '/auth',
websiteBasePath: '/auth',
},
recipeList: [
ThirdPartyEmailPassword.init({
providers: [
Google({
clientId:
'1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com',
clientSecret: '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',
}),
],
override: {
apis: (originalImplementation) => {
return {
...originalImplementation,
emailPasswordSignUpPOST: async function (input) {
if (
originalImplementation.emailPasswordSignUpPOST === undefined
) {
throw Error('Should never come here')
}
let response =
await originalImplementation.emailPasswordSignUpPOST(input)
if (response.status === 'OK') {
// TODO check if user exists in table
console.log('FROM emailPasswordSignUpPOST: ', response)
const doesUserExist = await checkUserExists(response.user.email)
if (!doesUserExist) {
await onNewUserSignUp(response.user.email, response.user.id)
}
}
return response
},
thirdPartySignInUpPOST: async function (input) {
if (originalImplementation.thirdPartySignInUpPOST === undefined) {
throw Error('Should never come here')
}
let response =
await originalImplementation.thirdPartySignInUpPOST(input)
console.log('FROM thirdPartySignInUpPOST: ', response)
if (response.status === 'OK') {
if (response.createdNewUser) {
// console.log('FROM thirdPartySignInUpPOST: ', response)
await onNewUserSignUp(response.user.email, response.user.id)
}
}
return response
},
}
},
},
}),
rp
05/06/2022, 2:10 PMmogalmahesh
05/06/2022, 2:12 PMrp
05/06/2022, 2:12 PMmogalmahesh
05/06/2022, 2:12 PMSession.init({
override: {
functions: (originalImplementation) => {
return {
...originalImplementation,
createNewSession: async function (input) {
let userId = input.userId
let teamId = 1
input.accessTokenPayload = {
...input.accessTokenPayload,
teamId,
}
return originalImplementation.createNewSession(input)
},
}
},
},
}), //
rp
05/06/2022, 2:14 PMlet google = Google({...});
providers: [
{
...google,
get: function (redirectURI: string | undefined, authCodeFromRequest: string | undefined, userContext: any) {
const getResult = google.get(redirectURI, authCodeFromRequest, userContext);
return {
...getResult,
getProfileInfo: async function (authCodeResponse: any, userContext: any) {
try {
const result = await getResult.getProfileInfo(authCodeResponse, userContext);
console.log(result);
return result;
} catch (err) {
console.log(err);
throw err;
}
}
};
}
},
],
mogalmahesh
05/06/2022, 2:15 PMError: Request failed with status code 400
at createError (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\core\createError.js:16:15)
at settle (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\adapters\http.js:269:11)
at IncomingMessage.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1346:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
rp
05/06/2022, 2:16 PMmogalmahesh
05/06/2022, 2:18 PMError: Request failed with status code 400
at createError (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\core\createError.js:16:15)
at settle (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\adapters\http.js:269:11)
at IncomingMessage.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1346:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
{
id: '101773664706409242493',
email: { id: 'mogal.mahesh33@gmail.com', isVerified: true }
}
rp
05/06/2022, 2:20 PMmogalmahesh
05/06/2022, 2:21 PMhttp://localhost:4000/auth/signinup 500 (Internal Server Error)
rp
05/06/2022, 2:22 PMmogalmahesh
05/06/2022, 2:25 PMrp
05/06/2022, 2:26 PMlet response =
await originalImplementation.thirdPartySignInUpPOST(input)
mogalmahesh
05/06/2022, 2:27 PMError: Request failed with status code 400
at createError (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\core\createError.js:16:15)
at settle (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\core\settle.js:17:12)
at IncomingMessage.handleStreamEnd (D:\code\projects\node\neospeak-backend\backend\node_modules\axios\lib\adapters\http.js:269:11)
rp
05/06/2022, 2:31 PMmogalmahesh
05/06/2022, 2:31 PMrp
05/06/2022, 2:32 PMmogalmahesh
05/06/2022, 2:35 PMhttp://localhost:3000/auth/callback/google
rp
05/06/2022, 2:38 PMmogalmahesh
05/06/2022, 2:40 PMrp
05/06/2022, 2:40 PMmogalmahesh
05/06/2022, 2:42 PMAuthorized JavaScript origins
when setting up the google console project?http://localhost:3000/auth/callback/{social_provider}
rp
05/06/2022, 2:45 PMmogalmahesh
05/06/2022, 2:46 PM