Open bksteckler opened 7 years ago
Seeing the same thing here.
I thought this might be due to the contacts API not being enabled in the google developer console, but that doesn't seem to be the issue. (Tried enabling/disabling contacts api, tried switching out the feeds argument for 'profile', etc. But that didn't help).
Try this. The BrowserWindow options are out of date, this module was made ages ago.
You only need to call getAccessToken() as it already calls getAuthorizationCode(). You need to hook the app 'window-all-closed' event as the app will by default quit when all windows are closed. Feel free to revert to async, should work fine.
Run in Electron 1.7.7
const electronGoogleOauth = require('electron-google-oauth');
const {app} = require('electron');
const browserWindowParams = {
center: true,
show: true,
resizable: false,
webPreferences: {
nodeIntegration: false
}
};
const clientId = '<clientid>';
const clientSecret = '<clientsecret>';
app.on('window-all-closed',() => {
})
app.on('ready', () => {
const googleOauth = electronGoogleOauth(browserWindowParams);
googleOauth.getAccessToken(
['https://www.googleapis.com/auth/plus.me',
'profile',
'email'],
clientId,
clientSecret
).then((result) => {
console.log('result',result);
})
});
@TimNZ thanks for sharing, works here!
@TimNZ Your code worked!! Thanks for sharing..
Thanks you men
Relatively new to electron so I am not sure if I am missing something in how I structured the code or if there is something amiss.
I have set up a main.js with the included code snippet and I can not seem to get a response from the getAuthorizationCode function to enable the code to continue past the async await call. I am able to get the log in window to appear along with the authentication consent screen. But at that point it redirects to my localhost page but the code is stuck in the async waiting process.
Any suggestions?