Skip to content

Commit

Permalink
chore(docs): cleanup Google Provider page
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Apr 27, 2024
1 parent 4ca3973 commit 164e677
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions docs/pages/getting-started/providers/google.mdx
Expand Up @@ -43,7 +43,7 @@ AUTH_GOOGLE_SECRET
<Code>
<Code.Next>

```ts filename="/auth.ts"
```ts filename="@/auth.ts"
import NextAuth from "next-auth"
import Google from "next-auth/providers/google"

Expand Down Expand Up @@ -77,9 +77,11 @@ app.use("/auth/*", ExpressAuth({ providers: [Google] }))
</Code.Express>
</Code>

### 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
Expand All @@ -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,
Expand All @@ -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") {
Expand All @@ -121,6 +124,5 @@ const options = {
return true // Do different verification for other providers that don't have `email_verified`
},
}
...
}
})
```

0 comments on commit 164e677

Please sign in to comment.