feat: implement Google OAuth with ThirdWeb Auth in declenup for account abstraction #51
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implement Google OAuth Authentication Flow with ThirdWeb SDK in Next.js
Description
This pull request implements the foundational Google OAuth authentication flow integrated with ThirdWeb's SDK in our Next.js application. The implementation allows users to sign in with their Google accounts, links their Google identity to a ThirdWeb wallet address, and manages tokens and sessions securely. This establishes a secure connection between Google identities and our web3 application, enhancing user authentication and enabling web3-native features.
Key Features
next-auth(Auth.js), with support for refresh tokens and secure token management./dashboard) by requiring both Google and ThirdWeb authentication.Changes Made
next-authfor Google OAuth authentication.GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,NEXTAUTH_SECRET, andNEXTAUTH_URLto.env.local(not committed for security).pages/api/auth/[...nextauth].ts: Configures NextAuth with Google OAuth provider, including token and session callbacks.components/SessionProvider.tsx: A wrapper component to provide NextAuth session context to the app.pages/api/auth/login.ts: A custom API endpoint to handle ThirdWeb Auth, linking Googleid_tokento a ThirdWeb wallet address and storing the session in a cookie.middleware.ts: Next.js middleware to protect routes by checking both NextAuth and ThirdWeb sessions.pages/_app.tsx: Wrapped the app withSessionProviderandThirdwebProviderto enable session and wallet context.pages/index.tsx: Updated the homepage to include Google Sign-In, ThirdWeb wallet connection, and session state handling.httpOnlycookies for ThirdWeb session storage (not encrypted in this PR; see To-Do for production encryption).openid,profile,email).close issue
#39