Uncaught gapi.auth2.ExternallyVisibleError: Invalid cookiePolicy, Uncaught Error: listen EADDRINUSE ::: 8070 in Electron - PullRequest
0 голосов
/ 14 марта 2019

Я пытаюсь заставить гугл выходить через OAuth2.0 в электронном

Я прочитал этот комментарий, поэтому я тоже создал server.js

API входа в Google работает только на работающем веб-сервере.

это то, что я сделал, чтобы начать проект и получил ошибки

  1. узел server.js
  2. npm start

Uncaught Error: listen EADDRINUSE ::: 8070 Uncaught uO {сообщение: "Недопустимая cookiePolicy", стек: "gapi.auth2.ExternallyVisibleError: Неверный файл cookieP… pis.google.com / js / platform.js? Onload = init: 18: 356) "}

Uncaught Error: прослушать EADDRINUSE ::: 8070

server.js

console.log("server start")
var http = require('http');

//create a server object:
var server =http.createServer(function (req, res) {
    res.write('Hello World!'); //write a response to the client
    res.end('test'); //end the response
}).listen(8070); //the server object listens on port 8080
server.on('listening',function(){
    console.log('ok, server is running');
});

index.html

<script>
      var gauth;
     function checkLoginStatus() {
        var loginBtn = document.querySelector('#loginBtn');
        var nameTxt = document.querySelector('#name');

        if (gauth.isSignedIn.get()) {
            console.log("logined");
            loginBtn.value = 'Logout'
            var profile=gauth.currentUser.get().getBasicProfile();
            nameTxt.innerHTML='Welcome <strong>'+profile.getName()+'</strong'
        }
        else {
            console.log("loged out");
            loginBtn.value = 'Login'
            nameTxt.innerHTML='';
        }
    }
    function init() {
        console.log("init")
        gapi.load('auth2', function () {
            console.log("auth2");

            gauth = gapi.auth2.init(
                {client_id: '1067161273424-gud6khml7r3bssi35u2rj5lchepj25bo.apps.googleusercontent.com'}
            ).then(function () {
                console.log("gapi done");
            })

            gauth.then(function () {
                console.log("google auth success");
                checkLoginStatus();

            }, function () {
                console.log("google auth faill");
            })
        });
    }
</script>

<script>
  // You can also require other files to run in this process
  require('./renderer.js')
</script>

<span id="name"></span>
<input type="button" id="loginBtn" value="checking.." onclick="
if(this.value==='Login'){
gauth.signIn().then(function() {
     console.log('gauth.signIn()');
checkLoginStatus();
});
}
else {
gauth.signOut().then(function() {
   console.log('gauth.signOut()');
checkLoginStatus();
});
}
">
    <script src="https://apis.google.com/js/platform.js?onload=init" async defer></script>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...