google api應用入門
TRANSCRIPT
GOOGLE API應用入門
MiCloud Robin / Simon
● 漫遊Google API● Google的API工具
○ API Console介紹○ API Explore介紹
● 從認證開始○ OAuth2
● Google API的使用○ 從Calendar API開始○ 玩玩Drive API
● 淺談進階的API操作 - Apps Script
Outline
Why Here...Cloud Changes the Developer
曾幾何時...● system and os● network setup● install what I need● mail sdk● sms bridge● backup and archive● socket protocol● using versioning for
develop● ...
現在...● cloud machine● vpc and permission● software preload● email service● sms service● object storage● restful protocal● git supported
deploy● ...
So....
Familiar cloud to be your weapon... Focus Core Business to Earn Money...
漫遊Google API - 從服務開始
SERVICE
API
漫遊Google API - 這堂課很難(上)...
Start Implements of API
RESTSDK
Web
Mobile
Developers use non-standard language
Developers use standard toolkits
End users
End users
API使用流程 - 讀懂怎麼用
Active Your API
Read the Document
IntegrateAuthenticateRequest API
Integrate
Learning Resources -https://developers.google.com/
Google API Console - Services
API Name
APIOn/Off
Notes for limit
Help page & documents
Google API Console - Access Control
Access Control
Project Info
Project Setting
ID info list
Google API Console - Reports
Usage Report
After Turn ON API....
What is API...
Condition Input
Resource Output
Google API Explore
Google API Explore - Multi-Versions
Google API Explore - Auth
Operation Scope
Google API Explore - Query
Google API Explore - REST & Results
REST Request
Sample
Request
Results
Google API Java Client
https://code.google.com/p/google-api-java-client/wiki/APIs#oauth2
Google API .NET Client
http://code.google.com/p/google-api-dotnet-client/wiki/APIs#Oauth2
Google API Node.js Client
https://github.com/google/google-api-nodejs-client
Other Language Support
Authenticate with Oauth2.0
● OAuth 2.0● OAuth 1.0● Hybrid protocol(OpenID
+ OAuth)● OpenID
Google Implemented Auth(s)
Oauth2 Client Login Flow
Redirect URL
to MiCloud
An Example - MiCloud Oauth Login1 2
3
Service Owner在Google的設定
Oauth優點
● 簡單:不管是 OAuth 服務提供者還是應用開發者,都很容易於理解與使用
● 安全:沒有涉及到使用者金鑰等資訊,更安全更靈活
● 開放:任何服務提供者都可以實現 OAuth,任何軟體發展商都可以使用 OAuth
Use of Google API - Calendar & Drive
What Calendar API can do...Functions● acl● calanderList● calendars● events● setting● ...
Connect Calendar API
Select your Operation..
Read the request and result
$ curl https://www.googleapis.com/calendar/v3/users/me/calendarList/mitac.com.tw_4gqp4u0bit7....o%40group.calendar.google.com -H "Authorization: Bearer ya29.AHES6ZSBtCsGQhpkmB....jcbOSY46jflrKKa4"{
"kind": "calendar#calendarListEntry", "etag": "\"hTTG_yZRNM6RHYgIq0uRTKezdKo/GXuSxc1o...Vkx1AgpzIOs\"", "id": "[email protected]", "summary": "7C2 假表", "description": "請貼上自己的假\nex: 姓名/事由", "timeZone": "Asia/Taipei", "colorId": "3", "backgroundColor": "#f83a22", "foregroundColor": "#000000", "selected": true, "accessRole": "owner"
}
API Explore Response
About Drive
Gapps +
Space
HTTP Server+
Google APIs
HTTP Access+
Market
● OA應用服務● 資料儲存
● 更多應用程式● Mobile應用● 全世界的展示平
台
● Simple Web● RESTful● 更多客製化的應
用● Google服務結合
Chrome store integrate
Drive best integrate platform
Use Apps Script
淺談一下Apps Script
● JavaScript like programming language● Cloud IDE integrate to Drive● Easy access to Google services● Some container integrate● Free!● Robust!
Apps Scripts目前種類
● Standalone Scripts● Container-Bound Scripts● Spreadsheet Custom Functions● Web Apps● Google Sites Gadgets● Container Extensions
Create Your Apps Script
What can I do - Simple HTTP Monitor
Piece of Code
Save data to sheet and setting chart
Or - Using RESTfulPiece of Code
Deploy & Publish
Testing in curl
URL Pattern:https://script.google.com/macros/s/:id/exec
Script ID
Testing in Ajax Code...
Apps Script可行的應用
● 結合Drive應用,做排成、資料顯示、互動...等● 結合Github Page, Cloud CMS等軟體,這些純
靜態HTML的頁面也可以有動態的結合● 結合Mobile的應用,讓Apps Script當做Mobile
的Server端,資料庫資源部分則可以使用Apps Script呼叫RDB, NDB, BigQuery...等
● 結合Chrome Extension的應用...
● Oauth 2: http://oauth.net/2/● Oauth1&2差異:
○ http://www.cnblogs.com/lingyun1120/archive/2011/12/12/2284788.html
○ http://blog.sina.com.cn/s/blog_4c9ba28501015ux6.html
● Google API Console: https://code.google.com/apis/console
● Google API Explore: https://code.google.com/apis/explorer/
● Apps Script Site: http://www.google.com/script/start/● Apps Script Docs: https://developers.google.com/apps-
script/
Reference