// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; export class V2 extends APIResource { /** * List active OAuth providers for the resolved tenant or root scope. * * The provider list is the set of active `login_methods` rows in the scope * resolved by the context middleware (`ContextManager.get_tenant()`). The resolved * scope is used as-is: a tenant scope never falls back to the root scope, and * inactive selections are omitted. The rows are returned in their configured * presentation order with provider type and display label. * * A host/default override applies only when the `DEFAULT_LOGIN_PROVIDER` feature * flag is enabled for the resolved scope and the host-mapped or default provider * ID exactly matches an active provider object in that scope. When the override is * absent or inactive, the complete active scoped list is returned unchanged. * * Args: request (Request): The request object. service * (AdminHostLoginProviderService): The admin host login provider service. user * (CurrentUser): The authenticated user. env_service (AdminEnvService): The admin * environment variables service. login_method_service (AdminLoginMethodService): * Scoped login method service. * * Returns: list[LoginProviderResponse]: Ordered active provider objects for the * resolved scope. */ retrieveProviders( params: V2RetrieveProvidersParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get('/auth/v2/providers', { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } export type V2RetrieveProvidersResponse = Array; export namespace V2RetrieveProvidersResponse { /** * Ordered public login provider object returned to the login UI. */ export interface V2RetrieveProvidersResponseItem { /** * StackAuth provider ID. */ provider_id: string; /** * Provider type of the login method. */ provider_type: 'credential' | 'google' | 'github' | 'microsoft' | 'djarum' | 'catapa' | 'oidc'; /** * Display label, or None to use the default label. */ display_name?: string | null; } } export interface V2RetrieveProvidersParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace V2 { export { type V2RetrieveProvidersResponse as V2RetrieveProvidersResponse, type V2RetrieveProvidersParams as V2RetrieveProvidersParams, }; }