Registry / auth-security / facebook-auth-nestjs

facebook-auth-nestjs

JSON →
library0.0.4jsnpmunverified

A NestJS module for Facebook login authentication. Current version 0.0.4. This package provides a simple way to integrate Facebook OAuth2 login into NestJS applications, wrapping the Facebook Graph API to retrieve user information. It supports synchronous (forRoot) and asynchronous (forRootAsync) configuration, and the service exposes a getUser method. Key differentiators: it is specifically designed for NestJS (leveraging its module system), uses the official NestJS patterns (forRoot/forRootAsync), and is minimal with no extra dependencies beyond NestJS core and common HTTP modules. Alternatives like passport-facebook require more configuration and are framework-agnostic.

npm install facebook-auth-nestjs
INSTALL
IMPORT
SIG · FACEBOOK-AUTH-NEST
F
facebook-auth-nestjs
auth-securityjavascriptv0.0.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FacebookAuthModule
import { FacebookAuthModule } from 'facebook-auth-nestjs'
import FacebookAuthModule from 'facebook-auth-nestjs'
Default import is not supported; use named import.
FacebookAuthService
import { FacebookAuthService } from 'facebook-auth-nestjs'
const FacebookAuthService = require('facebook-auth-nestjs').FacebookAuthService
The package may not export CommonJS. Use ESM imports.
FacebookAuthModuleOptions
import { FacebookAuthModuleOptions } from 'facebook-auth-nestjs'
import { FacebookAuthOptions } from 'facebook-auth-nestjs'
The interface is named FacebookAuthModuleOptions, not FacebookAuthOptions.

Registers the FacebookAuthModule with credentials using forRoot and demonstrates using the service to fetch a user's ID and name.

// In your AppModule import { Module } from '@nestjs/common'; import { FacebookAuthModule } from 'facebook-auth-nestjs'; @Module({ imports: [ FacebookAuthModule.forRoot({ clientId: process.env.FACEBOOK_CLIENT_ID ?? '', clientSecret: process.env.FACEBOOK_CLIENT_SECRET ?? '', }), ], }) export class AppModule {} // In a service import { Injectable } from '@nestjs/common'; import { FacebookAuthService } from 'facebook-auth-nestjs'; @Injectable() export class AuthService { constructor(private readonly facebookAuth: FacebookAuthService) {} async getUser(accessToken: string): Promise<{ id: string; name: string }> { return this.facebookAuth.getUser(accessToken, 'id', 'name'); } }
Debug
Known issues
gotchaThe 'getUser' method requires the fields to be passed as separate string arguments (e.g., 'id', 'name'), not as an array or a single comma-separated string.
fix
Use multiple string arguments: service.getUser(accessToken, 'id', 'name', 'email')
affects: >=0.0.1
gotchaThe package is for NestJS only; it cannot be used with plain Node.js or other frameworks.
fix
Use a general-purpose Facebook authentication library like passport-facebook for non-NestJS projects.
affects: >=0.0.1
gotchaUser fields beyond 'id', 'name', 'first_name', 'last_name' require explicit Facebook login scope permissions set on the frontend (e.g., user_birthday for birthday field).
fix
Request the necessary scopes on the frontend Facebook login call.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'facebook-auth-nestjs' or its corresponding type declarations.
The package may not be installed or TypeScript cannot resolve the types.
fix
Install the package: npm install facebook-auth-nestjs. Ensure no version mismatch.
The 'getUser' method expects at least 2 string arguments for fields.
Calling getUser with an array or a single string like 'id,name' instead of separate arguments.
fix
Use multiple arguments: this.service.getUser(token, 'id', 'name')
Invalid client credentials when calling getUser.
The clientId or clientSecret configured in forRoot is incorrect or not set.
fix
Verify your Facebook app credentials and ensure environment variables are loaded correctly.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
@nestjs/corerequiredRequired for NestJS module and dependency injection.
@nestjs/commonrequiredRequired for NestJS decorators and common utilities.
axiosrequiredUsed internally by facebook-auth-nestjs to make HTTP requests to Facebook Graph API.
@nestjs/axiosoptionalUsed for HTTP module integration with NestJS.
Agent activity
22 hits · last 30 days
node
18
OpenAI (training)
1
Resources
facebook-auth-nestjs — npm install facebook-auth-nestjs · libregistry