Add GoogleProvider to next-auth
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import NextAuth from 'next-auth'
|
import NextAuth from 'next-auth'
|
||||||
import CredentialsProvider from 'next-auth/providers/credentials'
|
import CredentialsProvider from 'next-auth/providers/credentials'
|
||||||
import TwitterProvider from 'next-auth/providers/twitter'
|
import TwitterProvider from 'next-auth/providers/twitter'
|
||||||
|
import GoogleProvider from 'next-auth/providers/google'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@@ -31,6 +32,10 @@ const options = {
|
|||||||
TwitterProvider({
|
TwitterProvider({
|
||||||
clientId: process.env.NEXT_PUBLIC_TWITTER_API_KEY,
|
clientId: process.env.NEXT_PUBLIC_TWITTER_API_KEY,
|
||||||
clientSecret: process.env.NEXT_PUBLIC_TWITTER_API_KEY_SECRET
|
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,
|
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}`
|
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 response = await fetch(url)
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|||||||
Reference in New Issue
Block a user