每次我单击带Facebook的登录名时,都会弹出一个弹出窗口,它告诉我URL已被阻止,我在Facebook应用程序的有效OAuth重定向URI中添加了本地主机,但仍然无法正常运行
<!-- File: src/Template/Users/login.ctp -->
<div class="form-signin">
<?= $this->Flash->render() ?>
<?= $this->Form->create() ?>
<h2><legend><?= __('Login')?></legend></h2>
<?= $this->Form->control('username',
array('class' => 'form-control',
'placeholder' => 'Enter your username')) ?>
<?= $this->Form->control('password',
array('class' => 'form-control',
'placeholder' => 'Enter your password')) ?>
<br>
<?= $this->Form->button(__('Login'), array('class' => 'btn btn-lg btn-btn-secondary btn-block')); ?>
<?= $this->Form->end() ?>
<hr>
<button type="button" name="button" onclick="fblogin()" class = "btn btn-primary btn-lg btn-block">Login with Facebook</button>
</div>
<script src="https://www.gstatic.com/firebasejs/5.7.3/firebase.js">. </script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyBCPLPyLTlkWyVs3XK4LpgE3ASEkf1Zf9w",
authDomain: "sendit-e8103.firebaseapp.com",
databaseURL: "https://sendit-e8103.firebaseio.com",
projectId: "sendit-e8103",
storageBucket: "sendit-e8103.appspot.com",
messagingSenderId: "150641419524"
};
firebase.initializeApp(config);
var provider = new firebase.auth.FacebookAuthProvider();
function fblogin() {
firebase.auth().signInWithPopup(provider)
.then(function(result){
var token = result.credential.accessToken;
var user = result.user;
var userName = user.displayName;
var userEmail = user.email;
var x = "<form method='POST' action='/ShareIT/users/fblogin'><input type='hidden' name='email' value='" + userEmail + "'></input><input type='hidden' name='name' value='" + userName + "'></input></form>";
var y = $(x);
$('body').append(y);
$(y).submit();
console.log(token);
console.log(user);
}).catch(function(error) {
console.log(error.code);
console.log(error.message);
})
}
</script>