What I am trying to do is use Firebase to authenticate with Google. Then get some data from Google Calendar.
I got the first part working. I can authenticate with Google and get user name, email ect., but once I add calendar
to the scope
it gives me 401 with Error: invalid_scope
.
Is it even possible to get that kind of data with 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>