Electron & ReactJS, Verwenden Sie BrowserWindow für die GitHub oAuth-Authentifizierung
Ich habe github's Electron with ReactJs eingerichtet. Also habe ich einBrowserWindow
und eine Reaktions-App, die in diesem Fenster gut funktioniert. Ich versuche, mich bei GitHub zu authentifizieren. Also, wenn ein Benutzer das @ drücLogin with Github
button, ein neuesBrowserWindow
öffnet sich und geht zur github authorize app url. Das Problem, das ich habe, hat mit dem @ zu tRuf zurüc und wie ich den Code vom Rückruf zurückbekomme. Ich habe es mit Apache Cordova und dem @ getInAppBrowser
aber es war anders, da ich @ verwenden konnlocalhost
als Rückruf.
Was ich bisher mit electron gemacht habe, eröffnet das neueBrowserWindow
aber nach der Autorisierung kann ich den Code nicht aus dem Rückruf erhalten.
var authWindow = new BrowserWindow({ width: 800, height: 600, show: true, 'always-on-top': true });
var githubUrl = 'https://github.com/login/oauth/authorize?';
var authUrl = githubUrl + 'client_id=' + options.client_id + '&scope=' + options.scope;
authWindow.loadUrl(authUrl);
authWindow.setVisibleOnAllWorkspaces(true);
authWindow.setResizable(false);
authWindow.addListener('page-title-updated', function(stream) {
console.log("LOADED");
console.log(JSON.stringify(stream));
console.log(stream);
var url = (typeof stream.url !== 'undefined' ? stream.url : stream.originalEvent.url),
raw_code = /code=([^&]*)/.exec(stream.url) || null,
code = (raw_code && raw_code.length > 1) ? raw_code[1] : null,
error = /\?error=(.+)$/.exec(strean.url);
if (code || error) {
authWindow.close();
}
// If there is a code in the callback, proceed to get token from github
if (code) {
// requestToken(code);
} else if (error) {
alert("Oops! Couldn't log authenticate you with using Github.");
}
});
Wo mache ichconsole.log(JSON.stringify(stream));
Ich bekomme{}
so ist es etwas, das das @ zu tun heventListener
? Irgendwelche Ideen oder bessere Ansätze?