Last active
December 14, 2015 09:09
-
-
Save silvolu/5062716 to your computer and use it in GitHub Desktop.
Write moments after authentication with gapi.auth.authorize().
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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