javascript - How do I use the Login Event in Electron Framework? - Stack Overflow

I would like some help understanding how the Event: 'login' feature in Electron Framework wor

I would like some help understanding how the Event: 'login' feature in Electron Framework works. Is it the low level implementation of the Password Autofill/Remember Password feature mon in browsers? I would like to use this to autofill a password in a webpage's login flow e.g.

const electron = require('electron')
const {app,BrowserWindow} = electron

app.on('ready', ()=>{
    let win = new BrowserWindow({
        width:800,
        height:600
    })
//This is where I'm confused
app.on('login', (event, webContents, request, authInfo, callback) => {
  event.preventDefault();
  callback('my_username', 'my_password');
});
//How to implement autofill to ?



    win.loadURL('')

});

Here is the link to the specification in their docs

I would like some help understanding how the Event: 'login' feature in Electron Framework works. Is it the low level implementation of the Password Autofill/Remember Password feature mon in browsers? I would like to use this to autofill a password in a webpage's login flow e.g.

const electron = require('electron')
const {app,BrowserWindow} = electron

app.on('ready', ()=>{
    let win = new BrowserWindow({
        width:800,
        height:600
    })
//This is where I'm confused
app.on('login', (event, webContents, request, authInfo, callback) => {
  event.preventDefault();
  callback('my_username', 'my_password');
});
//How to implement autofill to https://accounts.google.?



    win.loadURL('https://accounts.google.')

});

Here is the link to the specification in their docs

Share Improve this question asked Jul 9, 2016 at 11:00 yaboidukeyaboiduke 6701 gold badge7 silver badges20 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

It's not used for autofilling, it's used for basic auth. When you get those annoying browser prompts for user and password.

How to display HTTP 401 basic authentication dialog

It can also be used to support Proxies on a Corporate network. e.g. Basic, NTLM, etc. This'd be in response to a 407.

Update August 2023

Adding a basic example. The core code here needs to be application specific.

// Runs when electron requires credentials in response to a 401 or 407
app.on('login', async (event, webContents, request, authInfo, callback) => {
  // Call prevent default immediately as a delay, such as prompting on the UI for credentials, will
  // cause the default action to occur.
  event.preventDefault()

  // If the proxy credentials are cached use them otherwise prompt on the UI
  const [username, password] = <custom code to retrieve credentials, I display a prompt for the user to enter the credentials>

  callback(username, password)
})

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745138253a4613306.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信