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

Commit b20c9d7

Browse files
authored
Merge pull request #7 from uniquelyparticular/feature/cleanup
feat: cleaned up to match provider implementations
2 parents 8f0b2d4 + 207a7a0 commit b20c9d7

File tree

21 files changed

+15624
-155
lines changed

21 files changed

+15624
-155
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Describe the bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
28+
- OS: [e.g. iOS]
29+
- Browser [e.g. chrome, safari]
30+
- Version [e.g. 22]
31+
32+
**Smartphone (please complete the following information):**
33+
34+
- Device: [e.g. iPhone6]
35+
- OS: [e.g. iOS8.1]
36+
- Browser [e.g. stock browser, safari]
37+
- Version [e.g. 22]
38+
39+
**Additional context**
40+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
---
8+
9+
**Is your feature request related to a problem? Please describe.**
10+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11+
12+
**Describe the solution you'd like**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional context**
19+
Add any other context or screenshots about the feature request here.

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"jsxSingleQuote": true,
4+
"jsxBracketSameLine": true,
5+
"semi": true,
6+
"tabWidth": 2,
7+
"trailingComma": "none"
8+
}

README.md

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,95 @@
1-
# generic-oauth
1+
# @particular./serverless-oauth
2+
3+
[![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)
4+
5+
> 🎮 Minimal OAuth implementation using Serverless!
6+
7+
Built with [Micro](https://github.com/zeit/micro)! 🤩
8+
9+
## 🛠 Setup
10+
11+
Both a [Shopify](https://shopify.com) _and_ [Firebase](https://firebase.google.com) account are needed for this to function _(NOTE: this is only temporary)_.
12+
13+
Start ngrok (change ngrok port below from 3000 if going to run yarn dev on different port or if already in use)
14+
15+
```bash
16+
ngrok http 3000
17+
```
18+
19+
Make a note of the https `ngrok URL` provided.
20+
21+
---
22+
23+
Create a `.env` at the project root with the following credentials:
24+
25+
```dosini
26+
DEPLOYED_URI
27+
FIREBASE_API_KEY
28+
FIREBASE_PROJECT_ID
29+
SHOPIFY_OAUTH_SCOPES
30+
SHOPIFY_API_KEY
31+
SHOPIFY_API_SECRET
32+
```
33+
34+
---
35+
36+
`DEPLOYED_URI` should be set to your `ngrok URL` from above (ie. `https://312a9670.ngrok.io`)
37+
38+
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).
39+
40+
---
41+
42+
`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`.
43+
44+
Navigate to your [Shopify Partner Dashboard](https://partners.shopify.com/<<PartnerId>>/apps)'s App section and clicking `Create App`.
45+
46+
You can enter any value for `App Name`.
47+
48+
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`.
49+
50+
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`.
51+
52+
Click the `Create app` button to create your App Credentials and find your `SHOPIFY_API_KEY` and `SHOPIFY_API_SECRET`.
53+
54+
## 📦 Package
55+
56+
Run the following command to build the app
57+
58+
```bash
59+
yarn install
60+
```
61+
62+
Start the development server
63+
64+
```bash
65+
yarn dev
66+
```
67+
68+
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.
69+
70+
## ⛽️ Usage
71+
72+
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).
73+
74+
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`.
75+
76+
**_Make a note of the `access_token` provided as you will need it for making subsequent API calls._**
77+
78+
**NOTE**: this repository works extremely well with our `@particular./shopify-auth` package which is available via `npm` or at:
79+
https://github.com/uniquelyparticular/shopify-request.
80+
81+
```js
82+
const { createClient } = require('@particular./shopify-request');
83+
// import { createClient } from '@particular./shopify-request'
84+
85+
const shopify = new createClient({
86+
store_name: '...', //Shopify Store Name
87+
access_token: access_token //Shopify OAuth token received after registering as Public App and installing to Store above
88+
});
89+
```
90+
91+
## 🚀 Deploy
92+
93+
You can easily deploy this function to [now](https://now.sh).
94+
95+
_Contact [Adam Grohs](https://www.linkedin.com/in/adamgrohs/) @ [Particular.](https://uniquelyparticular.com) for any questions._

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
roots: ['<rootDir>/src', '<rootDir>/tests'],
3-
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$',
4-
moduleFileExtensions: ['js', 'jsx', 'json', 'node'],
2+
roots: ['<rootDir>/src', '<rootDir>/tests', '<rootDir>/spec'],
3+
transform: {
4+
'^.+\\.ts(x)?$': 'ts-jest',
5+
},
56
verbose: true,
6-
testURL: 'http://localhost/',
77
};

now.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "demo-generic-oauth",
3-
"alias": "particular-demo-generic-oauth.now.sh",
2+
"name": "demo-serverless-oauth",
3+
"alias": "particular-demo-serverless-oauth.now.sh",
44
"env": {
55
"NODE_ENV": "production",
6-
"DEPLOYED_URI": "https://particular-demo-generic-oauth.now.sh",
7-
"SHOPIFY_OAUTH_SCOPES": "@demo-generic-oauth-scopes",
6+
"DEPLOYED_URI": "https://particular-demo-serverless-oauth.now.sh",
7+
"SHOPIFY_OAUTH_SCOPES": "@demo-shopify-oauth-scopes",
88
"SHOPIFY_API_KEY": "@demo-shopify-api-key",
99
"SHOPIFY_API_SECRET": "@demo-shopify-api-secret",
1010
"FIREBASE_API_KEY": "@demo-firebase-api-key",
@@ -18,4 +18,4 @@
1818
"config": { "maxLambdaSize": "7mb" }
1919
}
2020
]
21-
}
21+
}

0 commit comments

Comments
 (0)