Social authentication
Offer Instagram as a social sign-in option in an Auth.js application.
Auth.js · Const
Auth.js provides a built-in Instagram OAuth integration. Configure it with an Instagram client ID and client secret, then register the documented callback URL.
Calling the Instagram provider with client credentials creates an OAuth configuration that Auth.js can use in its providers list. The provider uses OAuth 2 by default, and its callback endpoint must be registered with the provider. Instagram does not supply an email address through its API.
function default(config): OAuthConfig<Record<string, any>>| Name | Type | Description |
|---|---|---|
config | OAuthUserConfig<Record<string, any>> | Provider configuration, including the OAuth client credentials and any supported overrides. |
OAuthConfig<Record<string, any>>
instagram.import { Auth } from "@auth/core"
import Instagram from "@auth/core/providers/instagram"
const request = new Request("https://example.com")
const response = await Auth(request, {
providers: [
Instagram({
clientId: process.env.INSTAGRAM_CLIENT_ID!,
clientSecret: process.env.INSTAGRAM_CLIENT_SECRET!,
}),
],
})Registers Instagram as an OAuth provider in an Auth.js configuration.
Offer Instagram as a social sign-in option in an Auth.js application.
Use Auth.js’s predefined OAuth settings instead of implementing Instagram endpoints manually.
Adjust provider behavior when the default Instagram OAuth configuration does not fit an application.
Use the built-in Instagram provider and pass its client ID and client secret to the provider function. Add the resulting configuration to Auth.js’s providers list.
Follow-up: What callback endpoint should be registered? Use the application’s callback route ending in /api/auth/callback/instagram for the documented example.
The provider assumes Instagram follows OAuth 2 by default. Its factory returns an OAuth configuration that Auth.js can consume.
Follow-up: How can defaults be changed? Supply additional provider options to override the built-in OAuth configuration.
Instagram’s API does not return an email address, so application logic and account handling must not require one from this provider.
Follow-up: What local callback constraint must be handled? Facebook requires HTTPS even on localhost, so configure local TLS or use a proxy.
AuthOAuthConfigOAuthUserConfigcustomizing a built-in OAuth provider