Google updated its authentication system using OAuth 2.0.
https://developers.google.com/accounts/docs/OAuth2
The previous code:
<script type="text/javascript">
function logMeIn() {
scope = "https://www.google.com/
if (!google.accounts.user.
var token = google.accounts.user.login(
}else
{
alert("You're logged in already!");
}
}
</script>
should be changed to
<script src="https://apis.google.com/ js/client.js"></script>
<script type="text/javascript">
function logMeIn() {
var config = {
'client_id': 'your_id' ,
'scope': 'https://www.googleapis.com/ auth/calendar'
};
gapi.auth.authorize(config, function() {
console.log(gapi.auth);
console.log(gapi.auth.getToken(). access_token);
});
}
</script>
function logMeIn() {
var config = {
'client_id': 'your_id'
'scope': 'https://www.googleapis.com/
};
gapi.auth.authorize(config, function() {
console.log(gapi.auth);
console.log(gapi.auth.getToken().
});
}
</script>
So we need cliend_id in config to use Oauth 2.0. To get client_id
1) Login your Google account, go to
https://code.google.com/apis/console/.
2) Click on Create project…
3) Select Calendar API for calendar application
4) Create API access, Create oauth 2.0 client ID
https://code.google.com/apis/console/.
2) Click on Create project…
3) Select Calendar API for calendar application
4) Create API access, Create oauth 2.0 client ID
No comments:
Post a Comment