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

Commit f529e10

Browse files
committed
Renamed oAuthSettings members
1 parent 3d964a0 commit f529e10

File tree

5 files changed

+21
-18
lines changed

5 files changed

+21
-18
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ behavior you need to use the oAuthSettings parameter documented below.
9595
This setting is used when using OAUTH to authenticate a secure publishing channel or using preview support. Using this will ensure that a valid OAUTH bearer token will
9696
be available to the application. The setting takes the form of an object with the following fields:
9797
{
98-
CLIENT_ID: 'xxxxx',
99-
CLIENT_SECRET: 'xxxxx',
100-
CLIENT_SCOPE_URL: 'xxxxx',
101-
IDP_URL: 'https://identity.server.com'
98+
clientId: 'xxxxx',
99+
clientSecret: 'xxxxx',
100+
clientScopeUrl: 'xxxxx',
101+
idpUrl: 'https://identity.server.com'
102102
}
103103

104104
**`staticAssetDownload`** [optional]

gatsby-node.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ const AuthManagerToken = require('./src/authManager');
7979
* <b>oAuthSettings</b> (optional) This parameter defines the connection settings used to
8080
* connect to an oAuthServer so that the plugin can get an up-to-date and valid bearer token.
8181
* It takes the form if an object with the following fields:
82-
* CLIENT_ID: login id used on OAUTH provider
83-
* CLIENT_SECRET: password used on the OAUTH server
84-
* CLIENT_SCOPE_URL: scope URL for the request
85-
* IDP_URL: URL: URL used to connect to the OAUTH token provider
82+
* clientId: login id used on OAUTH provider
83+
* clientSecret: password used on the OAUTH server
84+
* clientScopeUrlL: scope URL for the request
85+
* idpUrl: URL: URL used to connect to the OAUTH token provider
8686
*
8787
*
8888
*/
@@ -107,8 +107,8 @@ exports.sourceNodes = async (
107107

108108
// Work around some clumsiness if this setting originally came from a .env file
109109
let oAuthObj = null;
110-
if (oAuthSettings && oAuthSettings.CLIENT_ID && oAuthSettings.CLIENT_SECRET
111-
&& oAuthSettings.CLIENT_SCOPE_URL && oAuthSettings.IDP_URL) {
110+
if (oAuthSettings && oAuthSettings.clientId && oAuthSettings.clientSecret
111+
&& oAuthSettings.clientScopeUrl && oAuthSettings.idpUrl) {
112112
oAuthObj = oAuthSettings;
113113
}
114114

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@oracle/gatsby-source-oce",
33
"description": "Gatsby source plugin for using Oracle Content Management as a data source",
44
"author": "Oracle America, Inc.",
5-
"version": "1.2.1",
5+
"version": "1.2.2",
66
"homepage": "https://github.com/oracle/gatsby-source-oce",
77
"repository": {
88
"type": "git",

src/authManager.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ const fetch = require('node-fetch');
1515

1616
exports.AuthManagerToken = async (authStr, authObj) => {
1717
const getBearerAuth = async (oAuthObject) => {
18-
// base64 encode CLIENT_ID:CLIENT_SECRET
19-
const authString = `${oAuthObject.CLIENT_ID}:${oAuthObject.CLIENT_SECRET}`;
18+
// base64 encode clientId:clientSecret
19+
const authString = `${oAuthObject.clientId}:${oAuthObject.clientSecret}`;
2020
const authValue = (Buffer.from(authString)).toString('base64');
2121

22-
// URL encode the CLIENT_SCOPE_URL
23-
const encodedScopeUrl = encodeURIComponent(oAuthObject.CLIENT_SCOPE_URL);
22+
// URL encode the clientScopeUrl
23+
const encodedScopeUrl = encodeURIComponent(oAuthObject.clientScopeUrl);
2424

2525
// build the full REST end point URL for getting the access token
26-
const restURL = new URL('/oauth2/v1/token', oAuthObject.IDP_URL);
26+
const restURL = new URL('/oauth2/v1/token', oAuthObject.idpUrl);
2727

2828
// make a request to the server to get the access token
2929
const response = await fetch(restURL.toString(), {

src/fetch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ exports.all = async (contentServer, channelToken, limit, query, oAuthStr, previe
3636

3737
// const pretty = (o) => JSON.stringify(o, null, 2);
3838

39+
// Handle preview being a string or a boolean
40+
const isPreview = (preview && (preview === true || preview === 'true'));
41+
3942
const fetchItem = async (id) => {
4043
let item = null;
41-
const itemUrl = preview === true ? `${contentServer}/content/preview/api/v1.1/items/${id}?channelToken=${channelToken}&expand=all` : `${contentServer}/content/published/api/v1.1/items/${id}?channelToken=${channelToken}&expand=all`;
44+
const itemUrl = isPreview === true ? `${contentServer}/content/preview/api/v1.1/items/${id}?channelToken=${channelToken}&expand=all` : `${contentServer}/content/published/api/v1.1/items/${id}?channelToken=${channelToken}&expand=all`;
4245

4346
try {
4447
const headers = new Headers({
@@ -74,7 +77,7 @@ exports.all = async (contentServer, channelToken, limit, query, oAuthStr, previe
7477
const allPublishedItemsUrl = `${contentServer}/content/published/api/v1.1/items?limit=${fetchLimit}&offset=0&totalResults=true&offset=0&channelToken=${channelToken}${fetchQuery}`;
7578
const allPreviewItemsUrl = `${contentServer}/content/preview/api/v1.1/items?limit=${fetchLimit}&offset=0&totalResults=true&offset=0&channelToken=${channelToken}${fetchQuery}`;
7679

77-
const allItemsUrl = preview === true ? allPreviewItemsUrl : allPublishedItemsUrl;
80+
const allItemsUrl = isPreview === true ? allPreviewItemsUrl : allPublishedItemsUrl;
7881

7982
// Fetch a response from the apiUrl
8083

0 commit comments

Comments
 (0)