-
-
Save mpicciolli/909d8d236ea1ad34dd8472046146d264 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const cors = require("cors"); | |
const morgan = require("morgan"); | |
const helmet = require("helmet"); | |
require('dotenv').config(); | |
let supertokens = require("supertokens-node"); | |
let Session = require("supertokens-node/recipe/session"); | |
let { verifySession } = require("supertokens-node/recipe/session/framework/express"); | |
let { middleware, errorHandler } = require("supertokens-node/framework/express"); | |
let ThirdPartyEmailPassword = require("supertokens-node/recipe/thirdpartyemailpassword"); | |
const apiPort = process.env.REACT_APP_API_PORT || 3001; | |
const apiDomain = process.env.REACT_APP_API_URL || `http://localhost:${apiPort}`; | |
const websitePort = process.env.REACT_APP_WEBSITE_PORT || 3000; | |
const websiteDomain = process.env.REACT_APP_WEBSITE_URL || `http://localhost:${websitePort}` | |
supertokens.init({ | |
framework: "express", | |
supertokens: { | |
connectionURI: "https://try.supertokens.io", | |
}, | |
appInfo: { | |
appName: "SuperTokens Demo App", | |
apiDomain, | |
websiteDomain | |
}, | |
recipeList: [ | |
ThirdPartyEmailPassword.init({ | |
providers: [ | |
ThirdPartyEmailPassword.Google({ | |
clientSecret: process.env.GOOGLE_CLIENT_SECRET, | |
clientId: process.env.GOOGLE_CLIENT_ID | |
}), | |
ThirdPartyEmailPassword.Github({ | |
clientSecret: process.env.GITHUB_CLIENT_SECRET, | |
clientId: process.env.GITHUB_CLIENT_ID | |
}), | |
], | |
override: { | |
apis: (originalImplementation) => { | |
return { | |
...originalImplementation, | |
signInUpPOST: async (input) => { | |
if (originalImplementation.signInUpPOST === undefined) { | |
throw Error("Should never come here"); | |
} | |
let response = await originalImplementation.signInUpPOST(input) | |
if (response.status === "OK") { | |
if (response.type === "thirdparty") { | |
let accessToken = response.authCodeResponse.access_token | |
console.log(response.authCodeResponse) // NO LOG | |
} | |
} | |
return response; | |
}, | |
} | |
} | |
}, | |
}), | |
Session.init() | |
] | |
}); | |
const app = express(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment