Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from uniquelyparticular/feature/cleanup
Browse files Browse the repository at this point in the history
feat: cleaned up to match provider implementations
  • Loading branch information
agrohs authored May 12, 2019
2 parents 8f0b2d4 + 207a7a0 commit b20c9d7
Show file tree
Hide file tree
Showing 21 changed files with 15,624 additions and 155 deletions.
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"singleQuote": true,
"jsxSingleQuote": true,
"jsxBracketSameLine": true,
"semi": true,
"tabWidth": 2,
"trailingComma": "none"
}
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,95 @@
# generic-oauth
# @particular./serverless-oauth

[![npm version](https://img.shields.io/npm/v/@particular./serverless-oauth.svg)](https://www.npmjs.com/package/@particular./serverless-oauth) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![CircleCI](https://img.shields.io/circleci/project/github/uniquelyparticular/serverless-oauth.svg?label=circleci)](https://circleci.com/gh/uniquelyparticular/serverless-oauth)

> 🎮 Minimal OAuth implementation using Serverless!
Built with [Micro](https://github.com/zeit/micro)! 🤩

## 🛠 Setup

Both a [Shopify](https://shopify.com) _and_ [Firebase](https://firebase.google.com) 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)

```bash
ngrok http 3000
```

Make a note of the https `ngrok URL` provided.

---

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

```dosini
DEPLOYED_URI
FIREBASE_API_KEY
FIREBASE_PROJECT_ID
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](https://console.firebase.google.com) 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`. Under the 'Get started by adding Firebase to your app', click the icon for `Web` < /> and then in that popup you will find your configuration information to use for `FIREBASE_API_KEY` (apiKey) and `FIREBASE_PROJECT_ID` (projectId).

---

`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](https://partners.shopify.com/<<PartnerId>>/apps)'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

```bash
yarn install
```

Start the development server

```bash
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](https://partners.shopify.com/<<PartnerId>>/apps)'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.

```js
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](https://now.sh).

_Contact [Adam Grohs](https://www.linkedin.com/in/adamgrohs/) @ [Particular.](https://uniquelyparticular.com) for any questions._
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
roots: ['<rootDir>/src', '<rootDir>/tests'],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$',
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
roots: ['<rootDir>/src', '<rootDir>/tests', '<rootDir>/spec'],
transform: {
'^.+\\.ts(x)?$': 'ts-jest',
},
verbose: true,
testURL: 'http://localhost/',
};
10 changes: 5 additions & 5 deletions now.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "demo-generic-oauth",
"alias": "particular-demo-generic-oauth.now.sh",
"name": "demo-serverless-oauth",
"alias": "particular-demo-serverless-oauth.now.sh",
"env": {
"NODE_ENV": "production",
"DEPLOYED_URI": "https://particular-demo-generic-oauth.now.sh",
"SHOPIFY_OAUTH_SCOPES": "@demo-generic-oauth-scopes",
"DEPLOYED_URI": "https://particular-demo-serverless-oauth.now.sh",
"SHOPIFY_OAUTH_SCOPES": "@demo-shopify-oauth-scopes",
"SHOPIFY_API_KEY": "@demo-shopify-api-key",
"SHOPIFY_API_SECRET": "@demo-shopify-api-secret",
"FIREBASE_API_KEY": "@demo-firebase-api-key",
Expand All @@ -18,4 +18,4 @@
"config": { "maxLambdaSize": "7mb" }
}
]
}
}
Loading

0 comments on commit b20c9d7

Please sign in to comment.