Skip to content

Instantly share code, notes, and snippets.

@silvolu
Last active December 14, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silvolu/5062716 to your computer and use it in GitHub Desktop.
Save silvolu/5062716 to your computer and use it in GitHub Desktop.
Write moments after authentication with gapi.auth.authorize().
<html>
<head>
<script src="https://apis.google.com/js/client.js"></script>
<script>
function auth() {
var config = {
'client_id': 'YOUR_CLIENT_ID',
'scope': 'https://www.googleapis.com/auth/plus.login',
'request_visible_actions': 'http://schemas.google.com/AddActivity'
};
gapi.auth.authorize(config, function() {
console.log('writing moment...');
var moment = {};
moment.type = 'http://schemas.google.com/AddActivity',
moment.target = {'url':
'https://developers.google.com/+/plugins/snippet/examples/thing'}
var request = gapi.client.request({
'path': 'plus/v1/people/me/moments/vault',
'method': 'POST',
'body': JSON.stringify(moment)
});
request.execute(function(result) {
console.log(result);
})
});
}
</script>
</head>
<body>
<button onclick="auth();">Authorize</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment