Google Provider
In this section, you will find detailed instructions on how to use Google Provider with FullAuth.
Follow google docs here:
https://developers.google.com/identity/protocols/oauth2Then add the following Authorized redirect URIs in your credentials configuration:
https://console.developers.google.com/apis/credentialshttp://your-domain/api/auth/callback/google
http://your-domain/api/auth/callback/mobile/google
Route Handler:
app/api/auth/[...fullauth]/route.ts
import { AuthOptions } from '@fullauth/core';
import { NextHandler } from '@fullauth/next';
import { GoogleProvider } from '@fullauth/core/providers';
export const authOptions: AuthOptions = {
providers: [
GoogleProvider({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
],
// Rest of code
};
const handler = NextHandler(authOptions);
export { handler as GET, handler as POST };
Multiple Providers:
app/api/auth/[...fullauth]/route.ts
import { AuthOptions } from '@fullauth/core';
import { NextHandler } from '@fullauth/next';
import { CredentialsProvider } from '@fullauth/core/providers';
export const authOptions: AuthOptions = {
providers: [
GoogleProvider({
id: 'google-user',
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
GoogleProvider({
id: 'google-admin',
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
}),
],
// Rest of code
};
const handler = NextHandler(authOptions);
export { handler as GET, handler as POST };