Giter Site home page Giter Site logo

vercel-upstash-tokens-cache's Introduction

AccessToken Cache Microservice

This application is meant to serve as an internal service to recover Auth0 M2M token for internal microservice communications.

Creating this tokens in serverless can increase the usaged quota of your Auth0 subscription, so the goal is to reuse the accessToken for the expiration provided by auth0 until a new one is requested.

The tokens are stored in Upstash

This is a Next.js project bootstrapped with create-next-app.

Set up

First clone the repo. Copy the .env.local.example file to .env.local (which will be ignored by Git):

cp .env.local.example .env.local

Configuring Upstash

  1. Go to the Upstash Console and create a new database

Upstash environment

UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN find the variables in the database details page in Upstash Console.

Auth0 environment

  • AUTH0_DOMAIN: Can be found in the Auth0 dashboard under settings.
  • AUTH0_CLIENT_ID: Can be found in the Auth0 dashboard under settings.
  • AUTH0_CLIENT_SECRET: Can be found in the Auth0 dashboard under settings.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/token. This endpoint can be edited in pages/api/token.ts.

This is a mocked endpoint to provide the M2M token as an easy way to validate the usage.

Tools used

  • Vercel for deployment & development environment.
  • Next.js with typescript support to run the application
  • Upstash for Serverless Redis (cache).
  • Auth0 for authorization management.

vercel-upstash-tokens-cache's People

Contributors

gabrielpanga avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  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.