Skip to content

Commit 4c15475

Browse files
authored
Merge pull request #66 from scientist-softserv/65-update-auth-url
65 update auth url
2 parents e72517e + f49c8d3 commit 4c15475

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.env.development.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CLIENT_SECRET= # Retrieved from the marketplace application show page under Deve
33
NEXTAUTH_SECRET= # Create this by running `openssl rand -base64 32` in your terminal. (https://next-auth.js.org/configuration/options#nextauth_secret)
44
NEXTAUTH_URL= # https://next-auth.js.org/configuration/options#nextauth_url
55
NEXT_PUBLIC_TOKEN= # Ref: "Provider Credentials" in the README
6+
NEXT_PUBLIC_CLIENT_DOMAIN= # Ref: "Creating The Marketplace App" in the README
67

78
# uncomment the “SENTRY” prefixed variables below if you are using sentry and need to catch errors in local dev
89
# SENTRY_AUTH_TOKEN= ref: https://github.com/getsentry/sentry-webpack-plugin#options (authToken)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ _The terms "client" and "provider" are fairly interchangeable in this applicatio
4848
| NEXTAUTH_SECRET | Yes | .env.development | Used to encrypt the NextAuth.js JWT |
4949
| NEXTAUTH_URL | Yes | .env.development | The authentication route used for NextAuth.js |
5050
| NEXT_PUBLIC_APP_BASE_URL | Yes | .env | The URL to the deployed webstore instance |
51+
| NEXT_PUBLIC_CLIENT_DOMAIN | No | .env.development | The domain attached to the Client App. Ref: Creating The Marketplace App |
5152
| NEXT_PUBLIC_PROVIDER_ID | Yes | .env | The identifier of the client's marketplace in the database |
5253
| NEXT_PUBLIC_PROVIDER_NAME | Yes | .env | The subdomain of the client's marketplace |
5354
| NEXT_PUBLIC_SCIENTIST_API_VERSION | Yes | .env | The version of the API we should be talking to |
@@ -60,7 +61,7 @@ _The terms "client" and "provider" are fairly interchangeable in this applicatio
6061
| SENTRY_URL | No | .env.development | The base URL of the Sentry instance |
6162

6263
### Creating The Marketplace App
63-
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._
64+
Ensure that a marketplace, e.g. client-name.<NEXT_PUBLIC_CLIENT_DOMAIN>.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._
6465
- Once you've clicked the "Applications" link mentioned above, press "New Application"
6566
- Only the application name is required for the moment. Name it the same as the provider name.
6667
- Save, and you should be redirected to the "Developer Details" page

pages/api/auth/[...nextauth].js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import NextAuth from 'next-auth'
22
import axios from 'axios'
33
// TODO(alishaevn): use the api value from https://github.com/assaydepot/rx/issues/21497 in the next phase
44
import { EXPIRATION_DURATION, getWebhookConfig, createWebhookConfig } from '../../../utils'
5+
const authorizationDomain = process.env.NEXT_PUBLIC_CLIENT_DOMAIN || 'scientist.com'
56

67
// For more information on each option (and a full list of options) go to: https://next-auth.js.org/configuration/options
78
const authOptions = {
@@ -14,8 +15,8 @@ const authOptions = {
1415
checks: ['pkce', 'state'],
1516
clientId: process.env.CLIENT_ID,
1617
clientSecret: process.env.CLIENT_SECRET,
17-
authorization: `https://${process.env.NEXT_PUBLIC_PROVIDER_NAME}.scientist.com/oauth/authorize`,
18-
token: `https://${process.env.NEXT_PUBLIC_PROVIDER_NAME}.scientist.com/oauth/token`,
18+
authorization: `https://${process.env.NEXT_PUBLIC_PROVIDER_NAME}.${authorizationDomain}/oauth/authorize`,
19+
token: `https://${process.env.NEXT_PUBLIC_PROVIDER_NAME}.${authorizationDomain}/oauth/token`,
1920
userinfo: {
2021
// The result of this function will be the input to the `profile` callback.
2122
async request(context) {
@@ -68,7 +69,7 @@ const authOptions = {
6869
*/
6970
const refreshAccessToken = async (token) => {
7071
try {
71-
const url = `https://${process.env.NEXT_PUBLIC_PROVIDER_NAME}.scientist.com/oauth/token`
72+
const url = `https://${process.env.NEXT_PUBLIC_PROVIDER_NAME}.${authorizationDomain}/oauth/token`
7273
const encodedString = Buffer.from(`${process.env.CLIENT_ID}:${process.env.CLIENT_SECRET}`).toString('base64')
7374
const params = new URLSearchParams({
7475
/* eslint-disable camelcase */

0 commit comments

Comments
 (0)