Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Auth.js · Const

Foursquare

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.

How it works

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.

Syntax

FourSquare(options)

Parameters

NameTypeDescription
optionsOAuthUserConfig<Record<string, any>> & { apiVersion: string }OAuth client configuration, including the client ID and client secret, plus the required API version date.

Returns

OAuthConfig<Record<string, any>>

Key points

  • Auth.js provides FourSquare as a built-in integration rather than requiring a custom provider implementation.
  • The provider is intended to add FourSquare login to an application.
  • The documented callback route ends with the provider identifier foursquare.
  • A default provider configuration is supplied, while supported options can be overridden.

Common mistakes

  • The provider requires apiVersion, and its value must use the YYYYMMDD format.
  • Auth.js treats this integration as OAuth 2 by default.

Example: Configure 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.

When to use it

Add FourSquare sign-in

Users need to authenticate with Foursquare in an Auth.js application.

Declare API compatibility

The application must target a specific Foursquare API compatibility date.

Override built-in defaults

The standard provider settings do not match an application’s needs.

Interview questions

QHow do you configure the FourSquare provider?

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.

QWhat callback URL does the documentation specify?

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.

QWhat are the function’s parameter and return types?

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.

  • OAuthConfig
  • OAuthUserConfig
  • customizing a built-in OAuth provider
  • Auth

Source: Foursquare - Auth.js. Checked 2026-10-15.