You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-47Lines changed: 24 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,58 +35,40 @@
35
35
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. -->
36
36
37
37
### Environment Variables
38
-
The following variables can be found in the `.env` and `.env.local` files.
39
-
40
-
| Name | Description | Required |
41
-
| ------------- | ------------- | ------------- |
42
-
| NEXT_PUBLIC_PROVIDER_NAME | The subdomain of the `marketplace-domain`| Yes |
43
-
| NEXT_PUBLIC_PROVIDER_ID | TODO | Yes |
44
-
| NEXT_PUBLIC_APP_BASE_URL | TODO | Yes |
45
-
| NEXT_PUBLIC_SCIENTIST_API_VERSION | TODO | Yes |
46
-
| NEXT_PUBLIC_WEBHOOK_URL | TODO | Yes |
47
-
| NEXTAUTH_SECRET | TODO | Yes |
48
-
| NEXTAUTH_URL | TODO | Yes |
49
-
| CLIENT_ID | TODO | Yes |
50
-
| CLIENT_SECRET | TODO | Yes |
51
-
| NEXT_PUBLIC_TOKEN | TODO | Yes |
52
-
| SENTRY_DSN | TODO | No |
53
-
| NEXT_PUBLIC_SENTRY_DSN | TODO | No |
54
-
| SENTRY_URL | TODO | No |
55
-
| SENTRY_ORG | TODO | No |
56
-
| SENTRY_PROJECT | TODO | No |
57
-
| SENTRY_AUTH_TOKEN | TODO | No |
38
+
_The terms "client" and "provider" are fairly interchangeable in this application. In the details below we will assume that the client's name is "webstore". Their marketplace would be at "webstore.scientist.com"._
| CLIENT_ID | Yes | .env.development | The identifier of the client's marketplace application |
43
+
| CLIENT_SECRET | Yes | .env.development | The secret related to the client's marketplace application |
44
+
| NEXTAUTH_SECRET | Yes | .env.development | Used to encrypt the NextAuth.js JWT |
45
+
| NEXTAUTH_URL | Yes | .env.development | The authentication route used for NextAuth.js |
46
+
| NEXT_PUBLIC_APP_BASE_URL | Yes | .env | The URL to the deployed webstore instance |
47
+
| NEXT_PUBLIC_PROVIDER_ID | Yes | .env | The identifier of the client's marketplace in the database |
48
+
| NEXT_PUBLIC_PROVIDER_NAME | Yes | .env | The subdomain of the client's marketplace |
49
+
| NEXT_PUBLIC_SCIENTIST_API_VERSION | Yes | .env | The version of the API we should be talking to |
50
+
| NEXT_PUBLIC_TOKEN | Yes | .env.development | The access token for logged out users. Ref: Provider Credentials|
51
+
| NEXT_PUBLIC_WEBHOOK_URL | Yes | .env | The URL that defines how user notifications are sent |
52
+
| SENTRY_AUTH_TOKEN | No | .env.development | The organization based auth token for the Sentry project |
53
+
| SENTRY_DSN | No | .env.development | The Data Source Name that allows monitoring of Sentry events |
54
+
| SENTRY_ORG | No | .env.development | The slug of the Sentry organization associated with the Sentry application |
55
+
| SENTRY_PROJECT | No | .env.development | The slug of the Sentry project associated with the Sentry application |
56
+
| SENTRY_URL | No | .env.development | The base URL of the Sentry instance |
58
57
59
58
#### Creating the marketplace app
60
-
Ensure that a marketplace, e.g. client-name.scientist.com, has been created by the Scientist.com Professional Services team. Once that exists, an app needs to be created on it by a developer with the proper permissions. This will allow for the environment variables in the `.env` and `.env.local` files to be set. You'll know if you have the proper developer permissions if once logged in on the client marketplace you can hover over your avatar and see "Applications" underneath the "Developer" settings.
59
+
Ensure that a marketplace, e.g. client-name.scientist.com, has been created by the Scientist.com Professional Services team. Once that exists, an application needs to be created on that marketplace by a developer with the proper permissions. This is how some of the environment variables are created. You'll know if you have the proper developer permissions if once logged in on the client marketplace, you can hover over your avatar and see "Applications" underneath the "Developer" settings._If you don't have the permissions, you need to request them, or ask someone with the permissions to complete the steps below._
61
60
- Once you've clicked the "Applications" link mentioned above, press "New Application"
62
-
- Only the application name is required for the moment
63
-
- Save and you should be redirected to the "Developer Details" page
61
+
- Only the application name is required for the moment. Name it the same as the provider name.
62
+
- Save, and you should be redirected to the "Developer Details" page
64
63
- There will be a button that says "Reveal Token"
65
64
- Click it. You'll need that token in the next step.
66
65
67
66
#### Provider ID
68
-
In an API GUI (e.g. Postman) make a GET request for `<marketplace-domain>/api/v2/providers.json?q=${YOUR_PROVIDER_NAME}`, e.g. `webstore.scientist.com/api/v2/providers.json?q=webstore`. Your authorization needs to be your token from the step above, formatted as a Bearer Token. Scroll to the `provider_refs` array and use the `provider_id` value to fill in the `NEXT_PUBLIC_PROVIDER_ID` variable below.
69
-
70
-
The `NEXT_PUBLIC_PROVIDER_NAME` needs to exactly match the subdomain of the `marketplace-domain`.
71
-
72
-
73
-
```bash
74
-
# .env
75
-
NEXT_PUBLIC_PROVIDER_NAME # e.g.: webstore
76
-
NEXT_PUBLIC_PROVIDER_ID # e.g.: 500
77
-
```
67
+
In an API GUI (e.g. Postman) make a GET request for `<marketplace>/api/v2/providers.json?q=${PROVIDER_NAME}`. Your authorization will be your token from the step above, formatted as a Bearer Token. e.g. `Bearer MY_TOKEN` Scroll to the `provider_refs` array and use the `provider_id` value to fill in the `NEXT_PUBLIC_PROVIDER_ID` variable.
78
68
79
69
#### Authentication
80
70
All API endpoints in this app require some form of authentication. A logged out user will be able to access the home and browse pages using a provider credential, while a logged in user can access all pages using their own credentials.
81
71
82
-
##### User Credentials
83
-
```bash
84
-
# .env.local
85
-
NEXTAUTH_SECRET # create this by running `openssl rand -base64 32` in your terminal
86
-
CLIENT_ID # retrieved from the provider storefront
87
-
CLIENT_SECRET # retrieved from the provider storefront
curl -X POST -H 'Authorization: Basic THISISAREALLYLONGALPHANUMERICSTRING' -d 'grant_type=client_credentials' https://NEXT_PUBLIC_PROVIDER_NAME.scientist.com/oauth/token/
99
81
```
100
82
101
-
The curl command will return a JSON object that has an `access_token` property. Store the value of that property as shown below:
102
-
103
-
```bash
104
-
# .env.local
105
-
NEXT_PUBLIC_TOKEN
106
-
```
83
+
The curl command will return a JSON object that has an `access_token` property. Set this as the `NEXT_PUBLIC_TOKEN`.
107
84
108
85
## Webstore Component Library
109
86
The webstore requires a [React component library](https://reactjs.org/docs/react-component.html) of view components. That dependency is packaged and released independently.
0 commit comments