Git Product home page Git Product logo

oauth2-gmail-email-extractor's Introduction

OAuth2-Gmail-Email-Extractor

This repository contains scripts to extract Gmail conversations using the Gmail API and Node.js.

Prerequisites

  • Node.js installed
  • Google Cloud Console project with Gmail API enabled

Steps to Get OAuth 2.0 Client Credentials from Google Cloud Console

  1. Visit the Google Cloud Console: Go to the Google Cloud Console.

  2. Create a Project (if necessary): If you don’t have an existing project, create a new project by clicking on the project drop-down menu at the top of the page and selecting "New Project." Follow the prompts to set up your project.

  3. Navigate to the API & Services Dashboard: In the Cloud Console, select the created or existing project. Then, navigate to the "APIs & Services" > "Dashboard" from the left-hand menu.

  4. Enable the Gmail API: Click on the "Enable APIs and Services" button. Search for "Gmail API" and select it from the results. Click the "Enable" button to enable the Gmail API for your project.

  5. Create OAuth 2.0 Client ID:

    • Navigate to "APIs & Services" > "Credentials."
    • Click on the "Create Credentials" drop-down and select "OAuth client ID."
    • Choose the application type (e.g., Web Application, Other, etc.).
    • Configure the authorized redirect URIs if needed. For development purposes, you can use http://localhost:3000/oauth2callback.
    • Click "Create" to generate your OAuth 2.0 credentials.
  6. Obtain Client ID and Client Secret: Once created, you'll be presented with the Client ID and Client Secret. Copy these values and use them in your token.js and app.js scripts accordingly.

  7. Configure Authorized Redirect URIs: Ensure that the authorized redirect URIs in your OAuth consent screen (from the Credentials page) match the redirect URIs used in your token.js script. This is important for the OAuth flow to work correctly.

Usage

Token.js

  • This script initiates the OAuth flow to get access and refresh tokens.
  • Replace CLIENT_ID, CLIENT_SECRET, and REDIRECT_URI in the script with your obtained credentials.
  • Run the script using node token.js and follow the authorization steps in the browser.

App.js

  • This script fetches Gmail conversations and stores them as text files.
  • Ensure you've completed the OAuth flow and obtained access tokens before running this script.
  • Modify the necessary variables (like userId) in the script according to your requirements.
  • Run the script using node app.js to extract Gmail conversations.

Notes

  • Ensure Node.js is properly configured and dependencies are installed (npm install).
  • Follow the steps carefully to obtain OAuth 2.0 client credentials for accessing the Gmail API.

oauth2-gmail-email-extractor's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.