---
title: "Discussion on \"Google OAuth using TypeScript, Express.js, Passport.js &  MongoDB\" | Hashnode"
description: "Discussion on \"Google OAuth using TypeScript, Express.js, Passport.js &  MongoDB\". Build a complete Node.js app with Google OAuth 2.0 authentication system using passport.js"
url: "https://hashnode.com/posts/google-oauth-using-typescript-expressjs-passportjs-and-mongodb/617a7f926584fe6ae5985c6d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Google OAuth using TypeScript, Express.js, Passport.js & MongoDB](https://samippoudel.hashnode.dev/google-oauth-using-typescript-expressjs-passportjs-and-mongodb?utm_source=hashnode&utm_medium=feed)

Build a complete Node.js app with Google OAuth 2.0 authentication system using passport.js

Oct 28, 2021 · 16 min read · samippoudel.hashnode.dev  
Updated Jan 8, 2022  
Read the article

-   [#nodejs](https://hashnode.com/tag/nodejs)
-   [#typescript](https://hashnode.com/tag/typescript)
-   [#express](https://hashnode.com/tag/express)
-   [#mongodb](https://hashnode.com/tag/mongodb)

## Written by

[Samip Poudel](https://hashnode.com/@SamipPoudel)

@SamipPoudel · Kathmandu,Nepal

  
[View profile](https://hashnode.com/@SamipPoudel)

Full-stack Developer & Designer

## Responses 1

Markdown supported · ⌘↵ to post

[Dec 30, 2023](https://hashnode.com/posts/google-oauth-using-typescript-expressjs-passportjs-and-mongodb/617a7f926584fe6ae5985c6d/comment/6590172e8b01e644a2626b4b)

I think to connect to mongoose we might need to connect this way.

```
mongoose.connect(MONGO_URI).then(() => {
  console.log("connected to mongodb");
}).catch((e) => {
  console.log("could not connect to mongodb", e);
});
```

We would als need to install `@types/cookie-session`

And I think the logout function should be implemented this way

```
router.get("/logout", (req: Request, res: Response) => {
  req.logout(function(err) {
    if (err) {
      console.error('error when logging out', err);
    }
    res.redirect("/");
  });

});
```
