我想要做的是使用Firebase與Google進行身份驗證。然後從Google日曆中獲取一些數據。Firebase身份驗證和Google日曆
我得到了第一部分的工作。我可以通過Google進行身份驗證並獲取用戶名,電子郵件等,但是一旦我將calendar
添加到scope
,它就會給我401與Error: invalid_scope
。
它甚至有可能通過Firebase獲得這種數據嗎?
HTML
<a href="#auth" id="auth">login please</a>
<a href="#auth" id="calendar">calendar</a>
JS
<script src="https://cdn.firebase.com/js/client/2.2.2/firebase.js"></script>
<script src="js/jquery.js"></script>
<script>
$("#auth").click(function() {
var ref = new Firebase("https://<my-super-cool-app>.firebaseio.com/");
ref.authWithOAuthPopup("google", function(error, authData) {
if (error) {
console.log("Login Failed!", error);
console.log(error);
} else {
console.log("Authenticated successfully with payload:", authData);
}
}, {
"scope": "email, calendar"
});
return false;
});
$("#calendar").click(function() {
$.getJSON('https://www.googleapis.com/calendar/v3/users/me/calendarList', function(data) {
console.log(data);
});
});
</script>
</body>
</html>
這是多麼費事。 :S我希望Firebase只會擴展他們的圖書館以方便訪問Google Calendar ... – mesqueeb 2018-02-17 09:00:48