Skip to content

GoogleProvider

Reference doc for the `GoogleProvider`.

Use this provider to authenticate with Google. Supports both OAuth2 and OIDC.

Using OAuth

import { GoogleProvider } from "@openauthjs/openauth/provider/google"
export default issuer({
providers: {
google: GoogleProvider({
clientId: "1234567890",
clientSecret: "0987654321"
})
}
})

Using OIDC

import { GoogleOidcProvider } from "@openauthjs/openauth/provider/google"
export default issuer({
providers: {
google: GoogleOidcProvider({
clientId: "1234567890"
})
}
})

Methods

GoogleOidcProvider

GoogleOidcProvider(config)

Parameters

Returns Provider

Create a Google OIDC provider.

This is useful if you just want to verify the user’s email address.

GoogleOidcProvider({
clientId: "1234567890"
})

GoogleProvider

GoogleProvider(config)

Parameters

Returns Provider

Create a Google OAuth2 provider.

GoogleProvider({
clientId: "1234567890",
clientSecret: "0987654321"
})

GoogleConfig

GoogleConfig.clientID

Type string

The client ID.

This is just a string to identify your app.

{
clientID: "my-client"
}

GoogleConfig.clientSecret

Type string

The client secret.

This is a private key that’s used to authenticate your app. It should be kept secret.

{
clientSecret: "0987654321"
}

GoogleConfig.query?

Type Record<string, string>

Any additional parameters that you want to pass to the authorization endpoint.

{
query: {
access_type: "offline",
prompt: "consent"
}
}

GoogleConfig.scopes

Type string[]

A list of OAuth scopes that you want to request.

{
scopes: ["email", "profile"]
}

GoogleOidcConfig

GoogleOidcConfig.clientID

Type string

The client ID.

This is just a string to identify your app.

{
clientID: "my-client"
}

GoogleOidcConfig.query?

Type Record<string, string>

Any additional parameters that you want to pass to the authorization endpoint.

{
query: {
prompt: "consent"
}
}

GoogleOidcConfig.scopes?

Type string[]

A list of OIDC scopes that you want to request.

{
scopes: ["openid", "profile", "email"]
}