我想要做的是使用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