Giter VIP home page Giter VIP logo

dsl's Introduction

Node.js OAuth 2.0 Quickstart

A quickstart app for integrators looking to use HubSpot's OAuth 2.0. Written in Node.js.

Note: This app does not store any data in a persistent way, so restarting the app will clear the retrieved access tokens.

What the app does

  1. Redirect to HubSpot's OAuth 2.0 server

    When you open your browser to http://localhost:3000/install, the app will redirect you to the authorization page on HubSpot's server. Here you will choose which account you'd like to install the app in and give consent for it to act on your behalf. When this is complete, HubSpot will redirect you back to the app.

  2. Exchange an authorization code for access tokens

    Now that you're back in the app, it will retrieve an access token and refresh token from HubSpot's server, using an authorization code that was supplied by HubSpot when you granted access to the app.

  3. Retrieve a contact

    When the app has received an access token, it will redirect you to http://localhost:3000/. It will then use the access token to make a query to HubSpot's Contacts API, and display the retrieved contact's name on the page.

Prerequisites

Before running the quickstart app, make sure you have:

  1. The tools required to run using the method of your choice:
  2. A free HubSpot developer account (sign up)
  3. An app associated with your developer account (create an app)
  4. A HubSpot account to install the app in (you can use an existing one, or create a test account)

Note: You must be a super-admin for the account that you want to install the app in.

Option 1: Running locally using Node.js

  1. Clone the repository:
    $ git clone [email protected]:HubSpot/oauth-quickstart-nodejs.git
  2. Create a .env file in the root of the repository with the ID and secret for your app (found on the app settings page), eg:
    CLIENT_ID='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
    CLIENT_SECRET='yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy'
    SCOPE='crm.contacts.read,forms'
    
    You can also add a SCOPE environment variable to specify a custom set of scopes. The scopes can be separated by a comma, space, or URL-encoded space (%20)
  3. From the root of the repository, run:
    $ yarn install
    $ yarn start
  4. Open your browser to http://localhost:3000/install to kick off the OAuth 2.0 flow

Option 2: Running in a Docker container

  1. Build an image of the quickstart app
$ docker build -t hs-oauth-quickstart:latest git://github.com/HubSpot/oauth-quickstart-nodejs.git
  1. Run a container with the new image
$ docker run --init -it -p 3000:3000 -e CLIENT_SECRET=$CLIENT_SECRET -e CLIENT_ID=$CLIENT_ID -e SCOPE=contacts,forms hs-oauth-quickstart:latest

dsl's People

Contributors

egoodhall avatar markhazlewood avatar zman81988 avatar dependabot[bot] avatar thtg88 avatar zrrobbins avatar

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.