npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@particular./serverless-oauth

v1.2.0

Published

Please contact Particular. via [email protected] for any questions

Downloads

18

Readme

@particular./serverless-oauth

npm version semantic-release code style: prettier CircleCI dependency status: david

🎮 Minimal OAuth implementation using Serverless!

Built with Micro! 🤩

🛠 Setup

Both a Shopify and Firebase account are needed for this to function (NOTE: this is only temporary).

Start ngrok (change ngrok port below from 3000 if going to run yarn dev on different port or if already in use)

ngrok http 3000

Make a note of the https ngrok URL provided.


Create a .env at the project root with the following credentials:

DEPLOYED_URI
FIREBASE_PROJECT_ID
FIREBASE_CLIENT_ID
FIREBASE_PRIVATE_KEY_ID
FIREBASE_PRIVATE_KEY
SHOPIFY_OAUTH_SCOPES
SHOPIFY_API_KEY
SHOPIFY_API_SECRET

DEPLOYED_URI should be set to your ngrok URL from above (ie. https://312a9670.ngrok.io)

Open the Firebase Console to create a new Project (or you can use an existing one) to use for storing temporary nonce date. Click Add Project, enter anything in the Project Name field then click Create Project. When you receive the 'Your new project is ready' confirmation, click Continue.

Go into the Settings for your new project (click gear icon) and click on Service Accounts tab. Click the Generate new private key button to download a JSON file containing your Service Account credentials.

From that JSON file, copy the following to your env entries: project_id >> FIREBASE_PROJECT_ID client_id >> FIREBASE_CLIENT_ID private_key_id >> FIREBASE_PRIVATE_KEY_ID

Grab the value of the key containing between -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----\n to set as the value of FIREBASE_PRIVATE_KEY *If deploying to Zeit Now instead of ngrok, make sure to replace \n in the string w/ \\n before storing as a secret.


SHOPIFY_OAUTH_SCOPES can be set to any of the following values: read_products,read_product_listings,read_customers,write_customers,write_orders,write_draft_orders,write_shipping,write_checkouts,read_shopify_payments_disputes,unauthenticated_read_product_listings,unauthenticated_write_checkouts,unauthenticated_write_customers.

Navigate to your Shopify Partner Dashboard's App section and clicking Create App.

You can enter any value for App Name.

In the App URL field, be sure to enter your ngrok URL (provided above) followed by /auth such that App URL looks something like https://312a9670.ngrok.io/auth.

In the Whitelisted redirection URL(s) field, be sure to enter your ngrok URL (provided above) followed by /auth/callback such that App URL looks something like https://312a9670.ngrok.io/auth/callback.

Click the Create app button to create your App Credentials and find your SHOPIFY_API_KEY and SHOPIFY_API_SECRET.

📦 Package

Run the following command to build the app

yarn install

Start the development server

yarn dev

The server will typically start on PORT 3000. If not, you'll need to restart ngrok to point to whatever server port you've started here.

⛽️ Usage

Once your server is up and running, navigate back to your Shopify Partner Dashboard's App section and clicking on the App you installed above (if you're not still there).

Open the Test your app accordian button > Select a store from the dropdown > Click the Install app on store button and follow the prompts to confirm your installation and Install Unlisted app.

Make a note of the access_token provided as you will need it for making subsequent API calls.

NOTE: this repository works extremely well with our @particular./shopify-auth package which is available via npm or at: https://github.com/uniquelyparticular/shopify-request.

const { createClient } = require('@particular./shopify-request');
// import { createClient } from '@particular./shopify-request'

const shopify = new createClient({
  store_name: '...', //Shopify Store Name
  access_token: access_token //Shopify OAuth token received after registering as Public App and installing to Store above
});

🚀 Deploy

You can easily deploy this function to now.

Contact Adam Grohs @ Particular. for any questions.