diff --git a/pages/api/auth/[...nextauth].js b/pages/api/auth/[...nextauth].js index ddd14de..368995d 100644 --- a/pages/api/auth/[...nextauth].js +++ b/pages/api/auth/[...nextauth].js @@ -1,6 +1,7 @@ import NextAuth from 'next-auth' import CredentialsProvider from 'next-auth/providers/credentials' import TwitterProvider from 'next-auth/providers/twitter' +import GoogleProvider from 'next-auth/providers/google' import axios from 'axios' const options = { @@ -31,6 +32,10 @@ const options = { TwitterProvider({ clientId: process.env.NEXT_PUBLIC_TWITTER_API_KEY, clientSecret: process.env.NEXT_PUBLIC_TWITTER_API_KEY_SECRET + }), + GoogleProvider({ + clientId: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_ID, + clientSecret: process.env.NEXT_PUBLIC_GOOGLE_CLIENT_SECRET }) ], secret: process.env.NEXT_PUBLIC_JWT_SECRET, @@ -46,6 +51,10 @@ const options = { url = `${process.env.NEXT_PUBLIC_API_URL}/auth/${account.provider}/callback?access_token=${account?.oauth_token}&access_secret=${account?.oauth_token_secret}` } + if (account.provider === 'google') { + url = `${process.env.NEXT_PUBLIC_API_URL}/auth/${account.provider}/callback?access_token=${account?.access_token}` + } + const response = await fetch(url) const data = await response.json()