{"id":18371,"library":"facebook-auth-nestjs","title":"facebook-auth-nestjs","description":"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.","status":"active","version":"0.0.4","language":"javascript","source_language":"en","source_url":"https://github.com/devMontagnini/facebook-auth-nestjs","tags":["javascript","nestjs","facebook","auth","typescript"],"install":[{"cmd":"npm install facebook-auth-nestjs","lang":"bash","label":"npm"},{"cmd":"yarn add facebook-auth-nestjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add facebook-auth-nestjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for NestJS module and dependency injection.","package":"@nestjs/core","optional":false},{"reason":"Required for NestJS decorators and common utilities.","package":"@nestjs/common","optional":false},{"reason":"Used internally by facebook-auth-nestjs to make HTTP requests to Facebook Graph API.","package":"axios","optional":false},{"reason":"Used for HTTP module integration with NestJS.","package":"@nestjs/axios","optional":true}],"imports":[{"note":"Default import is not supported; use named import.","wrong":"import FacebookAuthModule from 'facebook-auth-nestjs'","symbol":"FacebookAuthModule","correct":"import { FacebookAuthModule } from 'facebook-auth-nestjs'"},{"note":"The package may not export CommonJS. Use ESM imports.","wrong":"const FacebookAuthService = require('facebook-auth-nestjs').FacebookAuthService","symbol":"FacebookAuthService","correct":"import { FacebookAuthService } from 'facebook-auth-nestjs'"},{"note":"The interface is named FacebookAuthModuleOptions, not FacebookAuthOptions.","wrong":"import { FacebookAuthOptions } from 'facebook-auth-nestjs'","symbol":"FacebookAuthModuleOptions","correct":"import { FacebookAuthModuleOptions } from 'facebook-auth-nestjs'"}],"quickstart":{"code":"// In your AppModule\nimport { Module } from '@nestjs/common';\nimport { FacebookAuthModule } from 'facebook-auth-nestjs';\n\n@Module({\n  imports: [\n    FacebookAuthModule.forRoot({\n      clientId: process.env.FACEBOOK_CLIENT_ID ?? '',\n      clientSecret: process.env.FACEBOOK_CLIENT_SECRET ?? '',\n    }),\n  ],\n})\nexport class AppModule {}\n\n// In a service\nimport { Injectable } from '@nestjs/common';\nimport { FacebookAuthService } from 'facebook-auth-nestjs';\n\n@Injectable()\nexport class AuthService {\n  constructor(private readonly facebookAuth: FacebookAuthService) {}\n\n  async getUser(accessToken: string): Promise<{ id: string; name: string }> {\n    return this.facebookAuth.getUser(accessToken, 'id', 'name');\n  }\n}","lang":"typescript","description":"Registers the FacebookAuthModule with credentials using forRoot and demonstrates using the service to fetch a user's ID and name."},"warnings":[{"fix":"Use multiple string arguments: service.getUser(accessToken, 'id', 'name', 'email')","message":"The '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.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Use a general-purpose Facebook authentication library like passport-facebook for non-NestJS projects.","message":"The package is for NestJS only; it cannot be used with plain Node.js or other frameworks.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Request the necessary scopes on the frontend Facebook login call.","message":"User 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).","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install the package: npm install facebook-auth-nestjs. Ensure no version mismatch.","cause":"The package may not be installed or TypeScript cannot resolve the types.","error":"Cannot find module 'facebook-auth-nestjs' or its corresponding type declarations."},{"fix":"Use multiple arguments: this.service.getUser(token, 'id', 'name')","cause":"Calling getUser with an array or a single string like 'id,name' instead of separate arguments.","error":"The 'getUser' method expects at least 2 string arguments for fields."},{"fix":"Verify your Facebook app credentials and ensure environment variables are loaded correctly.","cause":"The clientId or clientSecret configured in forRoot is incorrect or not set.","error":"Invalid client credentials when calling getUser."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}