Yandex social login
Users need to sign in with Yandex accounts instead of creating a local password.
Auth.js · Const
Yandex is a built-in Auth.js OAuth provider. Configure it with a Yandex client ID and client secret, then include it in the Auth.js providers list.
The Yandex provider is a built-in OAuth configuration for Auth.js. Add it to the providers list and supply the Yandex application client ID and secret; Auth.js then uses the provider's defaults and handles the OAuth flow through the configured callback URL.
Yandex(options): OAuthConfig<YandexProfile>| Name | Type | Description |
|---|---|---|
options | OAuthUserConfig<YandexProfile> | OAuth configuration options for the Yandex provider, including the application credentials. |
OAuthConfig<YandexProfile>
import { Auth } from "@auth/core"
import Yandex from "@auth/core/providers/yandex"
const request = new Request(origin)
const response = await Auth(request, {
providers: [
Yandex({
clientId: process.env.YANDEX_CLIENT_ID!,
clientSecret: process.env.YANDEX_CLIENT_SECRET!,
}),
],
})Creates an Auth.js request handler configured with Yandex OAuth credentials.
Users need to sign in with Yandex accounts instead of creating a local password.
An application needs profile and contact data supplied by Yandex OAuth.
A service supports several OAuth providers through one Auth.js configuration.
Use the built-in Yandex provider and pass it in the Auth.js providers array. Configure it with the Yandex application’s clientId and clientSecret.
Follow-up: How would you change a provider default? Use the documented built-in OAuth-provider customization mechanism and override only the required option.
The callback endpoint is the application origin followed by /api/auth/callback/yandex. That URL must be configured for the Yandex OAuth application.
Follow-up: What should change for another deployment? Replace the example origin with the deployed application’s origin while retaining the provider-specific callback suffix.
The provider factory accepts OAuthUserConfig<YandexProfile> and returns OAuthConfig<YandexProfile>. The configuration therefore combines OAuth provider options with the Yandex profile type.
Follow-up: Why is the profile type useful? It describes the Yandex-specific user data available when mapping the provider response.
YandexProfileOAuthUserConfigOAuthConfigAuthcustomizing a built-in OAuth provider