diff --git a/README.md b/README.md index a83745f..1b9cfe2 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ Create a `.env` file at the root of the project. Add the following environment v GOOGLE_CLIENT_ID= GOOGLE_CLIENT_SECRET= +# setup SSO with Twitter +TWITTER_API_KEY= +TWITTER_API_KEY_SECRET= + # database DATABASE_URL=postgres://postgres:holaplex@localhost:5432/hub-starter POSTGRES_DB=hub-starter diff --git a/prisma/migrations/20230628180451_twitter_auth_fields/migration.sql b/prisma/migrations/20230628180451_twitter_auth_fields/migration.sql new file mode 100644 index 0000000..684ea5c --- /dev/null +++ b/prisma/migrations/20230628180451_twitter_auth_fields/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "Account" ADD COLUMN "oauth_token" TEXT, +ADD COLUMN "oauth_token_secret" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e1461d9..0f23527 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,6 +16,8 @@ model Account { providerAccountId String refresh_token String? @db.Text access_token String? @db.Text + oauth_token String? @db.Text + oauth_token_secret String? @db.Text expires_at Int? token_type String? scope String? diff --git a/src/app/login/Login.tsx b/src/app/login/Login.tsx index 47a7b37..af3bc5d 100644 --- a/src/app/login/Login.tsx +++ b/src/app/login/Login.tsx @@ -14,7 +14,13 @@ export default function Login() { className='rounded-lg px-20 py-3 bg-cta text-black hover:opacity-80 transition' onClick={() => signIn('google')} > - Continue with Google + Sign in with Google + + ); diff --git a/src/pages/api/auth/[...nextauth].ts b/src/pages/api/auth/[...nextauth].ts index 3bd20d9..4e83500 100644 --- a/src/pages/api/auth/[...nextauth].ts +++ b/src/pages/api/auth/[...nextauth].ts @@ -1,5 +1,6 @@ import NextAuth from "next-auth"; import GoogleProvider from "next-auth/providers/google"; +import TwitterProvider from "next-auth/providers/twitter"; import { PrismaAdapter } from "@next-auth/prisma-adapter"; import type { NextAuthOptions } from "next-auth"; import prisma from "@/modules/db"; @@ -74,6 +75,10 @@ export const authOptions: NextAuthOptions = { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }), + TwitterProvider({ + clientId: process.env.TWITTER_API_KEY as string, + clientSecret: process.env.TWITTER_API_KEY_SECRET as string, + }) ], events: { async createUser({ user }) {