Google accountã§Authenticationãã¾ãã¤ã¤Authorizationããã¾ãããå ´å
ãã¼ã¤ãä»æ¥ã®ãå ããã¯åªãããªãã®ã§ãã¿ã¤ãã«ã®2ã¤ãæ··åãã¦ããã¤æ»åãã
Google Accounts Authentication and Authorization — Google Developers
ã¨ã
ã¨ããè¦ã¦ãã¨ããä¾ãã°JavaScriptããAPIå©ãã¤ã¤ãè£å´ã§Google+ Platform — Google Developers使ã£ã¦ã¦ã¼ã¶èªè¨¼ããã¦ããããå ´åã¯ã©ãããããããã®ï¼ã©ããã©ã使ãã°ããã®ï¼ä¸ä½ã©ã£ã¡ãªã®ï¼ãã¨ããçåã«æãããã
æ£è§£ã¯google plus loginã®æ¹ã使ãã¤ã¤ãgapi.clientç¸å½ãèªã¿è¾¼ãã§ããã¦
<script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/client:plusone.js?onload=onLoadCallback'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script>
APIå©ãç¨ã®scopeãæå®ãã¤ã¤Authorization Requestéã£ã¦ï¼ä»¥ä¸ã¯Google+ sign-in buttonã使ãå ´åï¼
<span id="sign-in"> <span class="g-signin" data-callback="signinCallback" data-clientid="[YOUR CLIENT ID]" data-cookiepolicy="single_host_origin" data-scope="openid https://www.googleapis.com/auth/calendar.readonly" > </span> </span>
å¾ã¯æ®éã«JSããAPIãå©ãã°ãªã±ã¼ããã以éã®ã¦ã¼ã¶èªè¨¼ã«ã¤ãã¦ã¯ããã¥ã¡ã³ãã«æ¸ãã¦ããéããªã®ã§çç¥ã
function signinCallback(authResult) { console.log(authResult); if ( authResult.status.signed_in ) { gapi.client.load("calendar", "v3", processCalendar); } else { document.getElementById("sign-in").style.cssText += "display:inline;"; } } function processCalendar() { gapi.client.calendar.calendarList.list().execute(function(res) { console.log(res); }); }