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

Commit 3d964a0

Browse files
committed
Fixed issue with authorization
1 parent f6b6372 commit 3d964a0

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

package.json

Lines changed: 2 additions & 2 deletions
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.0",
5+
"version": "1.2.1",
66
"homepage": "https://github.com/oracle/gatsby-source-oce",
77
"repository": {
88
"type": "git",
@@ -27,7 +27,7 @@
2727
"lint": "eslint *.js ./src/*.js"
2828
},
2929
"dependencies": {
30-
"gatsby-source-filesystem": "~3.5.0",
30+
"gatsby-source-filesystem": "~3.13.0",
3131
"global-agent": "~2.1.12",
3232
"node-fetch": "~2.6.1"
3333
},

src/fetch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const fs = require('fs').promises;
2424
* data retrieved from the OCE server.
2525
*/
2626

27-
exports.all = async (contentServer, channelToken, limit, query, auth, preview, debug) => {
27+
exports.all = async (contentServer, channelToken, limit, query, oAuthStr, preview, debug) => {
2828
try {
2929
await fs.rmdir('.data', { recursive: true });
3030
} catch (err) {
@@ -42,7 +42,7 @@ exports.all = async (contentServer, channelToken, limit, query, auth, preview, d
4242

4343
try {
4444
const headers = new Headers({
45-
Authorization: `${auth}`,
45+
Authorization: `${oAuthStr}`,
4646
Accept: '*/*',
4747
Connection: 'keep-alive',
4848
'User-Agent': 'oracle/gatsby-source-oce',
@@ -80,7 +80,7 @@ exports.all = async (contentServer, channelToken, limit, query, auth, preview, d
8080

8181
let response = null;
8282
const headers = new Headers({
83-
Authorization: `${auth}`,
83+
Authorization: `${oAuthStr}`,
8484
Accept: '*/*',
8585
Connection: 'keep-alive',
8686
'User-Agent': 'oracle/gatsby-source-oce',

src/process.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ exports.prepareForStaticDownload = async ({ staticAssetRootDir }) => {
148148

149149
// Async file download to public folder.
150150
async function downloadToPublic(
151-
fileUrl, storagePath, storageName, auth,
151+
fileUrl, storagePath, storageName, oAuthStr,
152152
) {
153153
// Make the subdirectory to store the file
154154
try {
@@ -159,7 +159,7 @@ async function downloadToPublic(
159159

160160
// Download the file
161161
const headers = new Headers({
162-
Authorization: `${auth}`,
162+
Authorization: `${oAuthStr}`,
163163
Accept: '*/*',
164164
Connection: 'keep-alive',
165165
'User-Agent': 'oracle/gatsby-source-oce',
@@ -187,7 +187,7 @@ exports.downloadMediaFilesToStaticDir = async ({
187187
staticAssetRootDir,
188188
staticUrlPrefix,
189189
renditions,
190-
auth,
190+
oAuthStr,
191191
}) => {
192192
const dataItemMap = new Map();
193193
// Build a map of files that we need to download
@@ -209,7 +209,7 @@ exports.downloadMediaFilesToStaticDir = async ({
209209

210210
const promises = [];
211211
dataItemMap.forEach(async (value) => {
212-
promises.push(downloadToPublic(value.fileUrl, value.storagePath, value.storageName, auth));
212+
promises.push(downloadToPublic(value.fileUrl, value.storagePath, value.storageName, oAuthStr));
213213
});
214214

215215
await Promise.all(promises);
@@ -224,7 +224,7 @@ exports.downloadMediaFiles = async ({
224224
createNodeId,
225225
touchNode,
226226
renditions,
227-
auth,
227+
oAuthStr,
228228
}) => Promise.all(
229229
entities.map(async (e) => {
230230
if (isDigitalAsset(e)) {
@@ -252,11 +252,11 @@ exports.downloadMediaFiles = async ({
252252
try {
253253
console.log(`downloading mediaFile ${mediaObject.url}`);
254254
let fileNode = null;
255-
// If auth is defined, the download will be from a preview (management) call or
255+
// If oAuthStr is defined, the download will be from a preview (management) call or
256256
// from a secure channel.
257257
let httpHeaders = '';
258-
if (auth !== '') {
259-
httpHeaders = { Authorization: `${auth}` };
258+
if (oAuthStr !== '') {
259+
httpHeaders = { Authorization: `${oAuthStr}` };
260260
}
261261
fileNode = await createRemoteFileNode({
262262
url: mediaObject.url,

0 commit comments

Comments
 (0)