From 164e677cf474f1827c3827bb060557ef48d917e6 Mon Sep 17 00:00:00 2001 From: ndom91 Date: Sat, 27 Apr 2024 19:19:51 +0200 Subject: [PATCH] chore(docs): cleanup Google Provider page --- .../getting-started/providers/google.mdx | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/pages/getting-started/providers/google.mdx b/docs/pages/getting-started/providers/google.mdx index 333488adcf..9379ad2481 100644 --- a/docs/pages/getting-started/providers/google.mdx +++ b/docs/pages/getting-started/providers/google.mdx @@ -43,7 +43,7 @@ AUTH_GOOGLE_SECRET -```ts filename="/auth.ts" +```ts filename="@/auth.ts" import NextAuth from "next-auth" import Google from "next-auth/providers/google" @@ -77,9 +77,11 @@ app.use("/auth/*", ExpressAuth({ providers: [Google] })) -### Notes +## Notes -1. Google only provides Refresh Token to an application the first time a user signs in. +### Refresh Token + +Google only provides Refresh Token to an application the first time a user signs in. To force Google to re-issue a Refresh Token, the user needs to remove the application from their account and sign in again: https://myaccount.google.com/permissions @@ -88,8 +90,8 @@ Alternatively, you can also pass options in the `params` object of `authorizatio If you need access to the RefreshToken or AccessToken for a Google account and you are not using a database to persist user accounts, this may be something you need to do. -```js filename="pages/api/auth/[...nextauth].js" -const options = { +```ts filename="app/api/auth/[...nextauth]/route.ts" +export const { handlers, auth, signIn, signOut } = NextAuth({ providers: [ GoogleProvider({ clientId: process.env.GOOGLE_ID, @@ -103,16 +105,17 @@ const options = { }, }), ], -} +}) ``` -2. Google also returns a `email_verified` boolean property in the OAuth profile. +### Email Verified + +Google also returns a `email_verified` boolean property in the OAuth profile. You can use this property to restrict access to people with verified accounts at a particular domain. -```js -const options = { - ... +```ts filename="@/auth.ts" +export const { handlers, auth, signIn, signOut } = NextAuth({ callbacks: { async signIn({ account, profile }) { if (account.provider === "google") { @@ -121,6 +124,5 @@ const options = { return true // Do different verification for other providers that don't have `email_verified` }, } - ... -} +}) ```