Add FourSquare sign-in
Users need to authenticate with Foursquare in an Auth.js application.
Auth.js · Const
FourSquare is a built-in Auth.js OAuth provider. Configure it with client credentials and a required YYYYMMDD-formatted API version, then register it in the providers list.
FourSquare is a built-in OAuth provider factory. Pass client credentials and the required YYYYMMDD apiVersion to FourSquare, then include the resulting provider in Auth.js configuration; sign-in returns through the documented callback route.
FourSquare(options)| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<Record<string, any>> & { apiVersion: string } | OAuth client configuration, including the client ID and client secret, plus the required API version date. |
OAuthConfig<Record<string, any>>
foursquare.import { Auth } from "@auth/core"
import FourSquare from "@auth/core/providers/foursquare"
const request = new Request(origin)
const response = await Auth(request, {
providers: [
FourSquare({
clientId: process.env.FOURSQUARE_CLIENT_ID,
clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
apiVersion: "20240101",
}),
],
})Registers FourSquare as an OAuth provider with credentials and the required API-version date.
Users need to authenticate with Foursquare in an Auth.js application.
The application must target a specific Foursquare API compatibility date.
The standard provider settings do not match an application’s needs.
FourSquare is a built-in Auth.js provider that returns an OAuth configuration when called. Configure it with clientId, clientSecret, and apiVersion, then add it to the providers array.
Follow-up: What extra setting distinguishes this provider from a minimal OAuth setup? It requires apiVersion in YYYYMMDD format because Foursquare uses that value to indicate the API-change date supported by the client.
The callback URL is https://example.com/api/auth/callback/foursquare. The provider must be registered under the FourSquare integration so Auth.js can route the OAuth response correctly.
Follow-up: How would you adapt the URL for another deployment? Replace the example host with the application’s public origin while retaining the Auth.js callback path and provider identifier.
The factory accepts OAuthUserConfig<Record<string, any>> together with an apiVersion string. It returns OAuthConfig<Record<string, any>>, which is suitable for the Auth providers configuration.
Follow-up: Why might the defaults need customization? The built-in configuration can be overridden for a particular use case using Auth.js’s built-in OAuth-provider customization approach.
OAuthConfigOAuthUserConfigcustomizing a built-in OAuth providerAuth