Auto update with amazon s3 - access denied error.
See original GitHub issueelectron-builder: 22.4.0
- Version:
electron-updater: 4.2.4
- Target: Windows
Hi, I am trying to implement auto-update feature with amazon s3 bucket which is public. Here is the error
09:17:38.427 > Handle rejected promise (HttpError: 403 Forbidden
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId>294A4B6CE5AC3E3E</RequestId><HostId>6bd+kF2iNiN04k443tMX24VabZHjO4BhY1l50y7wDzWiJQ+4nf4m6jsPTzFuG+51fnx+HNId4nLy0=</HostId></Error>"
Headers: {
"x-amz-request-id": "294A4B6CE5AC3E3E",
"x-amz-id-2": "6bd+kF2iN04k443tMX24VabZHjO4BhY1l50y7wDzWiJQ+4nf4m6jsPTzFuG+51fnx+HNId4nLy0=",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"date": "Tue, 17 Mar 2020 22:17:38 GMT",
"server": "AmazonS3"
}) here.
And here is my latest.yml
version: 0.1.21
files:
- url: MyElectronApp Setup 0.1.21.exe
sha512: shahshashahahsha
size: 71185572
path: MyElectronApp Setup 0.1.21.exe
sha512: shahshashahahsha
releaseDate: '2020-03-17T06:27:22.649Z'
And in my package.json
"build": {
"appId": "com.my.electron-app",
"productName": "MyElectronApp",
"copyright": "Copyright © 2019 ${author}",
"mac": {
"category": "public.app-category.utilities"
},
"files": [
"build/**/*",
"node_modules/**/*"
],
"directories": {
"buildResources": "assets"
},
"publish": {
"provider": "s3",
"bucket": "bucketname"
}
},
My aws security credentials are in my .env file
AWS_ACCESS_KEY_ID=examplefwefoiaenfi
AWS_SECRET_ACCESS_KEY=exampleafafwefaiemfef
And my electron.js file
const { ipcMain, app, BrowserWindow, ipcRenderer } = require('electron');
const path = require('path');
const isDev = require('electron-is-dev');
const os = require('os');
const { autoUpdater } = require('electron-updater');
const isElectron = require('is-electron');
const log = require('electron-log');
//Load Dev only modules
// if(isDev) {
// require('electron-reload');
// require('dotenv').load();
// }
let mainWindow;
let serverWindow;
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');
log.info('isDev = ', isDev);
log.info('isElectron = ', isElectron());
function createWindow() {
log.info('creating electron window...');
mainWindow = new BrowserWindow({
width: 1500,
height: 680,
webPreferences: {
nodeIntegration: true,
},
});
mainWindow.loadURL(isDev ? `http://localhost:3000/` : `file://${path.join(__dirname, '../build/index.html')}`);
if (isDev) {
//BrowserWindow.addDevToolsExtension('<location to your react chrome extension>');
mainWindow.webContents.openDevTools();
if (isElectron()) {
//Install Dev Tools using just Electron
BrowserWindow.addDevToolsExtension(
path.join(os.homedir(), '/AppData/Local/Google/Chrome/User Data/Default/Extensions/lmhkpmbekcpmknklioeibfkpmmfibljd/2.17.0_0')
)
BrowserWindow.addDevToolsExtension(
path.join(os.homedir(), '/AppData/Local/Google/Chrome/User Data/Default/Extensions/fmkadmapgofadopljbjfkapdkoienihi/4.4.0_0')
)
}
}
mainWindow.on('closed', () => mainWindow = null);
}
function startExpress() {
log.info('setting server');
//Create the server window.
serverWindow = new BrowserWindow(
{
width: 1500,
height: 680,
webPreferences: {
nodeIntegration: true,
}
}
// :
// {
// show: false
// }
);
// if(isDev) { serverWindow.webContents.openDevTools(); }
//console.log('server path', `file://${path.join(__dirname, '\\server\\server.html')}`);
serverWindow.loadURL(`file://${path.join(__dirname, '\\server\\server.html')}`)
}
app.on('ready', () => {
startExpress();
createWindow();
autoUpdater.checkForUpdatesAndNotify().then(function(val) {
log.info('Promise fulfilled ', val)
})
.catch(function(reason) {
log.error('Handle rejected promise (' + reason + ') here.')
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
ipcMain.on('catch-on-main', (event, args) => {
//Do stuff
})
ipcMain.on('get-app-version', (event) => {
console.log('appversion=', app.getVersion());
mainWindow.webContents.send('set-app-version', app.getVersion());
});
ipcMain.on('restart-app', () => {
console.log('restarting the app...');
autoUpdater.quitAndInstall();
});
ipcMain.on('server-running', () => {
console.log('ipcMain channel entered server-running');
mainWindow.webContents.send('relay-server-running');
})
autoUpdater.on('checking-for-update', () => {
log.info('Checking for update...');
sendStatusToWindow('Checking for update...');
})
autoUpdater.on('update-available', (info) => {
log.info('Update available');
sendStatusToWindow('Update available.');
})
autoUpdater.on('update-not-available', (info) => {
log.info('Update not available.');
sendStatusToWindow('Update not available.');
})
autoUpdater.on('download-update', () => {
log.info('downloading update...');
sendStatusToWindow('download-update.');
});
autoUpdater.on('error', (err) => {
log.info('Error in auto-updater' + err);
sendStatusToWindow('Error in auto-updater. ' + err);
})
autoUpdater.on('download-progress', (progressObj) => {
let log_message = "Download speed: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
log.info(log_message);
sendStatusToWindow(log_message);
})
autoUpdater.on('update-downloaded', (info) => {
log.info('Update downloaded.');
sendStatusToWindow('Update downloaded');
});
function sendStatusToWindow(text) {
log.info(text);
mainWindow.webContents.send('message', text);
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Troubleshoot 403 Access Denied errors from Amazon S3
My users are trying to access objects in my Amazon Simple Storage Service (Amazon S3) bucket, but Amazon S3 is returning the 403...
Read more >Troubleshoot AWS Glue job returning 403 access denied error
1. Open the IAM console. · 2. Open the IAM role that's associated to the AWS Glue job and requires access to the...
Read more >Why do I get Access Denied errors when I add objects to my ...
AWS Knowledge Center Videos. Why do I get Access Denied errors when I add objects to my S3 bucket even though I have...
Read more >Electron app using electron-updater with s3 causes access ...
n<Error><Code>AccessDenied</Code><Message>Access Denied</Message><RequestId> ... "server": "AmazonS3" } 16:10:31.335 > Error in auto-updater.
Read more >Fix 403 Access Denied errors - Amazon S3 - ActSupport
Examine the S3 Block Public Access settings for the account and bucket. Permissions that enable public read access can be overridden by these ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s the guide that I followed. Make sure to also set the region to your S3 region s3 config guide for both ~/.aws/credentials and ~/.aws/config. Setting the region was what finally made auto update work for me.
Thank you @Icecubelegacy , in my case the error was with the default
"acl": "public-read"
which since my bucket was not public(its intentionally only for Cloudfront) then the upload failed with permission denied since the aws user won’t have permission to make the items explicitly public, to solve that I added"acl": null
.