NestJS is a relatively new framework that has been growing in popularity for many good reasons. It has full support for TypeScript and it combines ...
For further actions, you may consider blocking this person and/or reporting abuse
you are my hero! Thank you for this article, it was very very useful...
when i git the localhost:3000/auth/facebook in the browser i do get a login screen by facebook. After login i do get an error from facebook:

I have a similar issue, but I solve it by adding an email scope on facebook app
I hope this one can help you guys
hey did you find the solution for this? I've been getting the exact same error, even though I have tried everything, I'm still stuck with this
Excellent article, thank you very much for sharing it; it’s been a great help.
As you explain, I can create a user via Facebook login or retrieve a user previously created in this way. But when I try to use a domain with https instead of localhost:3000, I always get these errors:
[Nest] 96 - 29/07/2026, 14:43:02 ERROR [ExceptionsHandler] FacebookTokenError: This authorisation code has already been used.in Strategy.parseErrorResponse (/opt/render/project/src/node_modules/passport-facebook/lib/strategy.js:198:12)
in OAuth2Strategy._createOAuthError (/opt/render/project/src/node_modules/passport-oauth2/lib/strategy.js:420:16)
in /opt/render/project/src/node_modules/passport-oauth2/lib/strategy.js:177:45
in /opt/render/project/src/node_modules/oauth/lib/oauth2.js:196:18
in passBackControl (/opt/render/project/src/node_modules/oauth/lib/oauth2.js:132:9)
in IncomingMessage.<anonymous> (/opt/render/project/src/node_modules/oauth/lib/oauth2.js:157:7)
in IncomingMessage.emit (node:events:520:35)
in endReadableNT (node:internal/streams/readable:1729:12)
in process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
type: “OAuthException”,
code: 100,
subcode: 36009,
traceID: “Af10pfooI0nWFe3jGSfUFBg”,
status: 500
}
The domain is included in Meta Developer App, just as I had to do with localhost:3000.
Could you please provide more information on what needs to be done?
I got an error, apparently it does not return the name and email, some help
dev-to-uploads.s3.amazonaws.com/i/...
I think this shows up if the email of user is not verified.
Wonderful article Sir....
Thank you.
How protect other routes ?
@Get("/products")
@UseGuards(AuthGuard("facebook")) ?
if i have also Google guard it will be like:
@Get("/products")
@UseGuards(AuthGuard("facebook"))
@UseGuards(AuthGuard("google"))
Amazing article! One thing to note is if your local front-end runs on a separate port you will have CORS errors with Facebook. To resolve, the front-end MUST use the same port as your server (localhost:3000 in this case) so you'll need to proxy your request made on front-end to get rid of the errors.
then how to implement logout ??
Thank for your sharing, may i ask how can i implement facebook login with graphql project? is it possible without @Req annotation?
Hello @linhtran28 , did you found a way to implemenent this?
Any news on this?
Thank King Elisha, hope you can create a lot of post like this <3
Good article. I have a question regarding the facebookLoginRedirect function. How are you able to access req.user as req is an Express object?
To anyone getting the "Sorry, something went wrong". Go to facebook app and allow "email" as a scope.
I am getting this error:
InternalOAuthError: Failed to obtain access token