Electron app Use OAuth 2.0 Authorization Code Flow

  • 1
  • Idea
  • Updated 8 months ago
I need intergate  OAuth 2.0 Authorization Code Flow  in electron desktop apps.when load AuthUri in electron window ,getting an Error AssertionError

var config = {
            authUri: 'https://platform.devtest.ringcentral.com/restapi/oauth/authorize?response_type=code&client_id=xR...',
            redirectUri: 'http://localhost:8080/callback',
        }
                const electron = require('electron')
                const BrowserWindow = electron.remote.BrowserWindow;
                var loginWindow = new BrowserWindow({
                    width: 640,
                    height: 480,
                    show: false
                });
                loginWindow.loadURL(config.authUri);
                // loginWindow.webContents.openDevTools();
                loginWindow.on('closed', () => {
                    loginWindow = null;
                });
                loginWindow.show()


Thanks in Advance 
Photo of Robert Raj

Robert Raj

  • 152 Points 100 badge 2x thumb

Posted 8 months ago

  • 1
Photo of Embbnux Ji

Embbnux Ji, Employee

  • 370 Points 250 badge 2x thumb
Hi @Robert, you need to disable nodeIntegration on login window, and use preload to add your electron codes.

```
const loginWindow = new BrowserWindow({
  width: 600,
  height: 680,
  webPreferences: {
    nodeIntegration: false,
    preload: path.join(__dirname, 'preload.js'),
  },
  backgroundColor: '#fcfcfc', });
loginWindow.loadURL(oAuthUri);
```
https://github.com/embbnux/ringcentral-widget-electron/blob/master/src/main.js#L84
Photo of Robert Raj

Robert Raj

  • 152 Points 100 badge 2x thumb
HI still i got same error
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,720 Points 5k badge 2x thumb
What is the error? Could you please paste it here?