Skip to content

Commit cb76a4c

Browse files
Updating default audience config values and logic (#382)
* updating default audience value * have to escape curly brackets in React JSX
1 parent aa24af3 commit cb76a4c

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

Sample-01/api-server.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const appOrigin = authConfig.appOrigin || `http://localhost:${appPort}`;
1414
if (
1515
!authConfig.domain ||
1616
!authConfig.audience ||
17-
authConfig.audience === "YOUR_API_IDENTIFIER"
17+
["{yourApiIdentifier}", "{API_IDENTIFIER}"].includes(authConfig.audience)
1818
) {
1919
console.log(
2020
"Exiting: Please make sure that auth_config.json is in place and populated with valid domain and audience values"

Sample-01/src/__tests__/config.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe("The config module", () => {
2727
});
2828

2929
it("should omit the audience if left at a default value", () => {
30-
mockConfig({ audience: "YOUR_API_IDENTIFIER" });
30+
mockConfig({ audience: "{yourApiIdentifier}" });
3131

3232
const { getConfig } = require("../config");
3333

Sample-01/src/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import configJson from "./auth_config.json";
22

33
export function getConfig() {
44
// Configure the audience here. By default, it will take whatever is in the config
5-
// (specified by the `audience` key) unless it's the default value of "YOUR_API_IDENTIFIER" (which
5+
// (specified by the `audience` key) unless it's the default value of "{yourApiIdentifier}" (which
66
// is what you get sometimes by using the Auth0 sample download tool from the quickstart page, if you
77
// don't have an API).
88
// If this resolves to `null`, the API page changes to show some helpful info about what to do
99
// with the audience.
1010
const audience =
11-
configJson.audience && configJson.audience !== "YOUR_API_IDENTIFIER"
11+
configJson.audience && configJson.audience !== "{yourApiIdentifier}"
1212
? configJson.audience
1313
: null;
1414

Sample-01/src/views/ExternalApi.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ export const ExternalApiComponent = () => {
1414
error: null,
1515
});
1616

17-
const {
18-
getAccessTokenSilently,
19-
loginWithPopup,
20-
getAccessTokenWithPopup,
21-
} = useAuth0();
17+
const { getAccessTokenSilently, loginWithPopup, getAccessTokenWithPopup } =
18+
useAuth0();
2219

2320
const handleConsent = async () => {
2421
try {
@@ -130,9 +127,9 @@ export const ExternalApiComponent = () => {
130127
<p>
131128
You can't call the API at the moment because your application does
132129
not have any configuration for <code>audience</code>, or it is
133-
using the default value of <code>YOUR_API_IDENTIFIER</code>. You
134-
might get this default value if you used the "Download Sample"
135-
feature of{" "}
130+
using the default value of{" "}
131+
<code>&#123;yourApiIdentifier&#125;</code>. You might get this
132+
default value if you used the "Download Sample" feature of{" "}
136133
<a href="https://auth0.com/docs/quickstart/spa/react">
137134
the quickstart guide
138135
</a>

0 commit comments

Comments
 (0)