OAuth & MongoDB Realm Serverless Functions

OAuth & MongoDB Realm Serverless Functions

We would need to authenticate using OAuth 2. I also knew that because we were building the app on MongoDB Realm Serverless functions. OAuth & MongoDB Realm Serverless Functions. You've worked with MongoDB Realm Functions in the past, and that you're comfortable with the concepts around calling REST-ish APIs.

I recently had the opportunity to work with  Lauren Schaefer and  Maxime Beugnet on a stats tracker for some YouTube statistics that we were tracking manually at the time.

I knew that to access the  YouTube API, we would need to authenticate using OAuth 2. I also knew that because we were building the app on MongoDB Realm Serverless functions, someone would probably need to write the implementation from scratch.

I've dealt with OAuth before, and I've even built client implementations before, so I thought I'd volunteer to take on the task of implementing this workflow. It turned out to be easier than I thought, and because it's such a common requirement, I'm documenting the process here, in case you need to do the same thing.

This post assumes that you've worked with MongoDB Realm Functions in the past, and that you're comfortable with the concepts around calling REST-ish APIs.

But first...

What the Heck is OAuth 2?

OAuth 2 is an authorization protocol which allows unrelated servers to allow authenticated access to their services, without sharing user credentials, such as your login password. What this means in this case is that YouTube will allow my Realm application to operate as if it was logged in as a MongoDB user.

There are some extra features for added control and security, like the ability to only allow access to certain functionality. In our case, the application will only need read-only access to the YouTube data, so there's no need to give it permission to delete MongoDB's YouTube videos!

mongodb serverless

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Query of MongoDB | MongoDB Command | MongoDB | Asp.Net Core Mvc

LIKE | COMMENT | SHARE | SUBSCRIBEIn this tutorial, I will discuss the basic query or command of MongoDB Database. We will learn how to Create, Delete, and ...

Install MongoDB Database | MongoDB | Asp.Net Core Mvc

LIKE | COMMENT | SHARE | SUBSCRIBEIn this tutorial, I will discuss how to install MongoDB Database.Blog: http://aspdotnetexplorer.blogspot.comLike our page -...

Insert & Save method in MongoDB | Inserting Document | CRUD Operation in MongoDB

LIKE | COMMENT | SHARE | SUBSCRIBEIn this tutorial, I will discuss the basic query or command of MongoDB Database. We will learn how to insert, Delete the d...

Execute MongoDB Command | Create, Drop and Select Database | MongoDB | Asp.Net Core Mvc

LIKE | COMMENT | SHARE | SUBSCRIBEIn this tutorial, I will discuss the basic query or command of MongoDB Database. We will learn how to Create, Delete, and ...

MongoDB Database and java applications

Enroll for free demo to acquire the best knowledge on the schema-less database from live industry experts through MongoDB training