-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,720 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,55 @@ | ||
# Account linking is not supported yet, we are actively working on the feature. | ||
![SuperTokens banner](https://raw.githubusercontent.com/supertokens/supertokens-logo/master/images/Artboard%20%E2%80%93%2027%402x.png) | ||
|
||
# SuperTokens Google one tap Demo app | ||
|
||
This demo app demonstrates the following use cases: | ||
|
||
- Thirdparty Login / Sign-up | ||
- Email Password Login / Sign-up | ||
- Logout | ||
- Session management & Calling APIs | ||
- Account linking | ||
|
||
## Project setup | ||
|
||
Clone the repo, enter the directory, and use `npm` to install the project dependencies: | ||
|
||
```bash | ||
git clone https://github.com/supertokens/supertokens-auth-react | ||
cd supertokens-auth-react/examples/with-thirdparty-google-onetap | ||
npm install | ||
cd frontend && npm install && cd ../ | ||
cd backend && npm install && cd ../ | ||
``` | ||
|
||
## Run the demo app | ||
|
||
This compiles and serves the React app and starts the backend API server on port 3001. | ||
|
||
```bash | ||
npm run start | ||
``` | ||
|
||
The app will start on `http://localhost:3000` | ||
|
||
## How it works | ||
|
||
TODO | ||
|
||
### On the frontend | ||
|
||
The demo uses the pre-built UI, but you can always build your own UI instead. | ||
|
||
TODO | ||
|
||
### On the backend | ||
|
||
TODO | ||
|
||
## Author | ||
|
||
Created with :heart: by the folks at supertokens.com. | ||
|
||
## License | ||
|
||
This project is licensed under the Apache 2.0 license. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import ThirdPartyEmailPassword from "supertokens-node/recipe/thirdpartyemailpassword"; | ||
import Session from "supertokens-node/recipe/session"; | ||
import Passwordless from "supertokens-node/recipe/passwordless"; | ||
import AccountLinking from "supertokens-node/recipe/accountlinking"; | ||
import EmailVerification from "supertokens-node/recipe/emailverification"; | ||
import { TypeInput } from "supertokens-node/types"; | ||
import UserMetadata from "supertokens-node/recipe/usermetadata"; | ||
import Dashboard from "supertokens-node/recipe/dashboard"; | ||
import { getUser } from "supertokens-node"; | ||
|
||
export function getApiDomain() { | ||
const apiPort = process.env.REACT_APP_API_PORT || 3001; | ||
const apiUrl = process.env.REACT_APP_API_URL || `http://localhost:${apiPort}`; | ||
return apiUrl; | ||
} | ||
|
||
export function getWebsiteDomain() { | ||
const websitePort = process.env.REACT_APP_WEBSITE_PORT || 3000; | ||
const websiteUrl = process.env.REACT_APP_WEBSITE_URL || `http://localhost:${websitePort}`; | ||
return websiteUrl; | ||
} | ||
|
||
export const SuperTokensConfig: TypeInput = { | ||
supertokens: { | ||
// this is the location of the SuperTokens core. | ||
connectionURI: "http://localhost:3567", | ||
}, | ||
appInfo: { | ||
appName: "SuperTokens Demo App", | ||
apiDomain: getApiDomain(), | ||
websiteDomain: getWebsiteDomain(), | ||
}, | ||
// recipeList contains all the modules that you want to | ||
// use from SuperTokens. See the full list here: https://supertokens.com/docs/guides | ||
recipeList: [ | ||
EmailVerification.init({ | ||
mode: "REQUIRED", | ||
}), | ||
UserMetadata.init(), | ||
AccountLinking.init({ | ||
shouldDoAutomaticAccountLinking: async (_newInfo, _user, _tenantId, context) => { | ||
if (context.doNotLink === true) { | ||
return { | ||
shouldAutomaticallyLink: false, | ||
}; | ||
} | ||
return { | ||
shouldAutomaticallyLink: true, | ||
shouldRequireVerification: true, | ||
}; | ||
}, | ||
}), | ||
ThirdPartyEmailPassword.init({ | ||
providers: [ | ||
// We have provided you with development keys which you can use for testing. | ||
// IMPORTANT: Please replace them with your own OAuth keys for production use. | ||
{ | ||
config: { | ||
thirdPartyId: "google", | ||
clients: [ | ||
{ | ||
clientId: "1060725074195-kmeum4crr01uirfl2op9kd5acmi9jutn.apps.googleusercontent.com", | ||
clientSecret: "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", | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
config: { | ||
thirdPartyId: "github", | ||
clients: [ | ||
{ | ||
clientId: "467101b197249757c71f", | ||
clientSecret: "e97051221f4b6426e8fe8d51486396703012f5bd", | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
config: { | ||
thirdPartyId: "apple", | ||
clients: [ | ||
{ | ||
clientId: "4398792-io.supertokens.example.service", | ||
additionalConfig: { | ||
keyId: "7M48Y4RYDL", | ||
privateKey: | ||
"-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgu8gXs+XYkqXD6Ala9Sf/iJXzhbwcoG5dMh1OonpdJUmgCgYIKoZIzj0DAQehRANCAASfrvlFbFCYqn3I2zeknYXLwtH30JuOKestDbSfZYxZNMqhF/OzdZFTV0zc5u5s3eN+oCWbnvl0hM+9IW0UlkdA\n-----END PRIVATE KEY-----", | ||
teamId: "YWQCXGJRJL", | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
override: { | ||
apis: (oI) => ({ | ||
...oI, | ||
}), | ||
}, | ||
}), | ||
Passwordless.init({ | ||
contactMethod: "PHONE", | ||
flowType: "USER_INPUT_CODE_AND_MAGIC_LINK", | ||
}), | ||
Session.init(), | ||
Dashboard.init(), | ||
], | ||
}; |
Oops, something went wrong.