SlideShare a Scribd company logo
1 of 60
Download to read offline
Google API로 만드는

더욱 더 풍부한 백오피스
MooYeol Prescott Lee
Software Engineer @ Law&Company
발표자 소개
• 이무열

• Software Engineer @
LawCompany

• mooyoul@gmail.com

• https://github.com/mooyoul

• https://www.linkedin.com/
in/mooyoul
Google API를 통해
더 풍부한 백오피스를 만드는 방법
인증
인증
• 두 독립적인 웹앱이 존재한다고 가정
• 일반적인 사진 인화 웹사이트 (A) / 사진 공유 웹사이트 (B)
• 나는 (A)을 만드는 개발자
• (B)에는 사진을 올릴 수 있는 API가 있음

아이디/패스워드 조합의 인증만 가능한 상황
• 이번에 고객이 (B)에 올린 사진을 가져와 인화하는 기능을
추가하려고 함
인증
인증
• 만약 내가 악의적인 목적을 가지고 사용자의 비밀 정보를 수
집한다면?
• 유저 입장에서 신뢰할 수 없음
• 제 3자에게 비밀번호 노출 가능성 (하필 비밀번호가 공인
인증서 비밀번호라면?)
• 읽는 권한만 필요한데 모든 권한이 들어오네?
• 접근 제어가 불가능
OAuth
OAuth
• 표준
• 사용자의 비밀 정보를 입력받을 필요 없이 안전하게 인증 수
행
• Content Provider

컨텐츠 제공자, 이전 슬라이드의 사진 공유 웹사이트 (B)
• Content Consumer

컨텐츠 소비자, 이전 슬라이드의 사진 인화 웹사이트 (A)
OAuth Flow
OAuth Flow
OAuth Flow
OAuth References
• OAuth

https://oauth.net/
• RFC5849 - The OAuth 1.0 Protocol

https://tools.ietf.org/html/rfc5849
• RFC6749 - The OAuth 2.0 Authorization Framework

https://tools.ietf.org/html/rfc6749
• Yahoo! Developer - OAuth Flow

https://developer.yahoo.com/oauth/guide/images/
oauth_graph.gif
Google Identity Platform
Google Identity Platform
• 사용자 인증이 필요한 API에 접근하거나, 사용자 리소스에
접근이 필요한 경우 사용자 인증이 필요하다
• OAuth2 기반 인증 제공
• 일반적인 3-legged 형태의 인증 뿐만 아니라 Service
Account를 통해 2-legged (Server to Server)로도 인증 가
능
3-legged OAuth
• OAuth로 인증을 수행하는 대부분의 플랫폼에서 사용하는
인증 방식
• e.g.) Google ID로 로그인

=> 3-legged OAuth
• User Interaction 필요

Application에서

인증받고 싶은데..
Service Account
• Service Account는 가상의 Google ID를 생성하고,

각 서비스에서 권한 위임을 통해 리소스 접근
• mooyoul@gmail.com 계정에서

some-id@developer.gserviceaccount.com 라는 Service
Account를 생성하더라도,

some-id@developer.gserviceaccount.com 는
mooyoul@gmail.com 의 리소스에 접근 불가능
• 독립적인 계정이므로 서비스 계정에서 생성한 컨텐츠 (e.g.
Spreadsheet 문서) 역시 공유하거나 소유권을 변경하지 않으
면 mooyoul@gmail.com 에서 접근 불가능
Service Account
2-legged OAuth
3-legged vs 2-legged
Creating Service Account
• Service Account 생성은
API Console에서 가능



https://
console.developers.google.com/
permissions/serviceaccounts?hl=ko
Obtaining Access Token
• JSON Web Token (JWT) 생성

base64_encoded_header.base64_encoded_claim_set.bas
e64_encoded_signature
• 생성한 JWT로 Access Token 요청
• Access Token 응답 처리
without 

googleapi
module
vs
with googleapi module (built-in JWT based auth)
Identity Platform References
• Google Identity Platform

https://developers.google.com/identity/
• Google Identity Platform - OAuth 2.0 Overview

https://developers.google.com/identity/protocols/OAuth2
• Google Identity Platform - OAuth 2.0 for Server-side Web Apps

https://developers.google.com/identity/protocols/OAuth2WebServer
• Google Identity Platform - OAuth 2.0 API Scopes

https://developers.google.com/identity/protocols/googlescopes
• Google Identity Platform - OAuth 2.0 for Service Accounts

https://developers.google.com/identity/protocols/OAuth2ServiceAccount
• Google Identity Platform - Application Default Credentials

https://developers.google.com/identity/protocols/application-default-credentials
• Google API Node.js Client Library - Using JWT Service Tokens

https://github.com/google/google-api-nodejs-client/#using-jwt-service-tokens
(거의) 다 배웠습니다
Spreadsheets를 만드는 방법
• Google Drive API를 사용해서 CSV 업로드
• Google Apps Script
• Google Sheets API (구 Spreadsheets API)
Spreadsheets via Apps Script
• Drive API를 통해 CSV 업로드를 했더니…
• 휴대폰번호 “01012341234” => 숫자로 인식해
1012341234로 자동 변환되는 문제 발생
• Sheets API v3에서 cell-based 로 데이터를 밀어넣으려
니…
• batch API에서 자꾸 문제가 발생
Spreadsheets via Apps Script
515행 출력하는데 1.2분…
Sheets API v4 의 등장
Spreadsheets via Apps Script
🚫🚫
Sheets API

(구. Spreadsheets API)
Sheets API를 언제 쓰지?
• 백오피스에서 회원 목록 CSV/Excel 출력되게 해주세요
• 매일 XX시에 YY를 한 유저의 리스트를 엑셀로 저장해주세요
• XXX 이벤트가 발생하면 지정한 엑셀파일에 추가(append) 해
주세요
• 휴대폰 주소가 들어있는 엑셀파일 읽어서 문자 보내주세요
• 메일 주소가 들어있는 엑셀파일 읽어서 메일 보내주세요
• …
Sheets API
• Google Spreadsheets를 내 마음대로
• Spreadsheet 조회/생성/삭제

- Drive API를 통해서도 가능
• Sheet 조회/생성/수정/삭제
• 시트 데이터 조회/추가/수정/삭제 (V3: Row-based & Cell-based,
V4: A1 Notation)
• 기능을 조합하면 templating도 가능
• formula 또한 기본 지원
Sheets API
• https://docs.google.com/spreadsheets/d/
SPREADSHEET_ID/edit?pli=1#gid=SHEET_ID
• https://docs.google.com/spreadsheets/d/
1s0bXZu6nf7l04TOunn4paiz0fJ2pMV2CK4WKyeo8L4Q/
edit?pli=1#gid=495715675
• Spreadsheet ID

1s0bXZu6nf7l04TOunn4paiz0fJ2pMV2CK4WKyeo8L4Q
• Sheet ID (V3: Worksheet ID)

495715675
A1 Notation
• Sheet1!A1:B2

Sheet1의 (첫번째 행, 첫번째 열)에서 (두번째 행, 두번째 열)까지의 모든 셀
• Sheet1!A:A 

Sheet1의 첫번째 열의 모든 셀
• Sheet1!1:2

Sheet1의 첫번째 행부터 두번째 행까지의 모든 셀
• Sheet1!A5:A

Sheet1의 첫번째 열의 다섯번째 행부터 마지막 행까지의 모든 셀
• A1:B2

스프레드시트 내 첫번째 시트 첫번째 행의 두 셀
• Sheet1

Sheet1의 모든 셀
List Spreadsheets
Create spreadsheet
‘my awesome spreadsheet’ 라는 이름을 가진

스프레드시트 생성
Append values
TARGET_SPREADSHEET_ID 스프레드시트의 emails 시트에 값 추가
Demo
References
• Google Sheets API Guide

https://developers.google.com/sheets/guides/concepts
• Google Sheets API - Reading & Writing Values

https://developers.google.com/sheets/guides/values
• Google Sheets API - REST Reference

https://developers.google.com/sheets/reference/rest/
Google Analytics

Core Reporting API
GA Core Reporting API
• Google Analytics Dashboard에서 보는 (거의 모든) 데이터를 가져올 수 있음
• 2016년 1월 1일 부터 오늘까지의 Users
• 2016년 10월의 총 PV
• 어제 /some-path/depth2 페이지에 방문한 User/PV 수
• 최근 7주간 awesome-event 이벤트 카테고리의

일 이벤트 수
• 기간별 PV 비교 (10월 1주차 PV, 10월 2주차 PV…)
• Segment, Cohort, … 기타 등등
Metrics & Dimensions
• 측정할 Metric과 Dimension은 미리 알아두면 좋음. 엄청 많기 때문에…
• Dimensions & Metrics Explorer 참고해 어느정도 눈에 익혀두면 좋음, 사
내 마케팅 팀의 도움을 받는것도 좋은 방법

https://developers.google.com/analytics/devguides/reporting/core/
dimsmets
• 개발시 reporting api를 매번 호출하는 것보다

Google Analytics Demos & Tools 에서 제공하는 Query Explorer를 사용
해 측정 대상 지표들을 점검하고 개발을 권장 (훨씬 더 빨리 개발할 수 있음)

https://ga-dev-tools.appspot.com/query-explorer/
• 단, 위 Query Explorer는 Version 3 API 이므로 Request Payload는
Version 4 API와는 다른 것에 주의
Demo
References
• Google Analytics Core Reporting API

https://developers.google.com/analytics/devguides/reporting/core/v4/
• Google Analytics Core Reporting REST Reference

https://developers.google.com/analytics/devguides/reporting/core/v4/rest/
v4/reports/batchGet
• Google Analytics Dimensions & Metrics Explorer

https://developers.google.com/analytics/devguides/reporting/core/dimsmets
• Google Analytics Demos & Tools

https://ga-dev-tools.appspot.com
• Google Analytics Query Explorer

https://ga-dev-tools.appspot.com/query-explorer/
Google Calendar API
Calendar API
• Google Calendar API 역시 Sheets API 와 비슷하게 제공되는
거의 모든 기능을 API로 제어할 수 있음
• 캘린더 리스트 조회
• 캘린더 내 일정 조회
• 특정 일정 조회
• 일정 추가 (반복되는 일정도 처리 가능)
• Push Notification (to registered server)
Demo
Use cases
Analytics Core Reporting API + Slack Webhook
Core Reporting API + Calendar API

PhantomJS + D3 + Slack Webhook
Core Reporting API + Sheets API
Q&A
감사합니다.

More Related Content

What's hot

Open api개발을 위한 자료1
Open api개발을 위한 자료1Open api개발을 위한 자료1
Open api개발을 위한 자료1도성 김
 
빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar
빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar
빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly WebinarAmazon Web Services Korea
 
Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬)
Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬) Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬)
Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬) Amazon Web Services Korea
 
AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇
AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇
AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇Amazon Web Services Korea
 
판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수
판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수
판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수Amazon Web Services Korea
 
[H3 2012] OAuth2 - API 인증을위한 만능 도구상자
[H3 2012] OAuth2 - API 인증을위한 만능 도구상자[H3 2012] OAuth2 - API 인증을위한 만능 도구상자
[H3 2012] OAuth2 - API 인증을위한 만능 도구상자KTH, 케이티하이텔
 
Naver 오픈api-마이그레이션가이드 20160913-리뷰
Naver 오픈api-마이그레이션가이드 20160913-리뷰Naver 오픈api-마이그레이션가이드 20160913-리뷰
Naver 오픈api-마이그레이션가이드 20160913-리뷰NAVER D2
 
Open API 발표자료 - 김연수
Open API 발표자료 - 김연수Open API 발표자료 - 김연수
Open API 발표자료 - 김연수Yeon Soo Kim
 

What's hot (8)

Open api개발을 위한 자료1
Open api개발을 위한 자료1Open api개발을 위한 자료1
Open api개발을 위한 자료1
 
빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar
빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar
빠른 모바일 인증 구현을 위한 Amazon Cognito 서비스 소개 :: 윤석찬 - AWS Monthly Webinar
 
Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬)
Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬) Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬)
Amazon Elastcsearch Service 소개 및 활용 방법 (윤석찬)
 
AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇
AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇
AWS DevDay 실습 가이드 - Rekognition 기반 Twitter봇
 
판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수
판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수
판교 개발자 데이 – 쉽고 안전한 Aws IoT 플랫폼 활용하기 – 이창수
 
[H3 2012] OAuth2 - API 인증을위한 만능 도구상자
[H3 2012] OAuth2 - API 인증을위한 만능 도구상자[H3 2012] OAuth2 - API 인증을위한 만능 도구상자
[H3 2012] OAuth2 - API 인증을위한 만능 도구상자
 
Naver 오픈api-마이그레이션가이드 20160913-리뷰
Naver 오픈api-마이그레이션가이드 20160913-리뷰Naver 오픈api-마이그레이션가이드 20160913-리뷰
Naver 오픈api-마이그레이션가이드 20160913-리뷰
 
Open API 발표자료 - 김연수
Open API 발표자료 - 김연수Open API 발표자료 - 김연수
Open API 발표자료 - 김연수
 

Similar to GDG Incheon Devfest 2016 - Google API로 만드는 더욱 더 풍부한 백오피스

소셜 네트워크 앱 개발
소셜 네트워크 앱 개발소셜 네트워크 앱 개발
소셜 네트워크 앱 개발Kenu, GwangNam Heo
 
Google Cloud NEXT'17 정리
Google Cloud NEXT'17 정리Google Cloud NEXT'17 정리
Google Cloud NEXT'17 정리Yongyoon Shin
 
[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)
[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)
[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)Sang Don Kim
 
How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)Channy Yun
 
Firebase for web (웹개발을 위한 파이어베이스) 2 Authentication
Firebase for web (웹개발을 위한 파이어베이스) 2 AuthenticationFirebase for web (웹개발을 위한 파이어베이스) 2 Authentication
Firebase for web (웹개발을 위한 파이어베이스) 2 Authentication승빈이네 공작소
 
[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드
[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드
[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드Atlassian 대한민국
 
Saturday Azure Live 1701 Azure WebApp 개념원리
Saturday Azure Live 1701 Azure WebApp 개념원리Saturday Azure Live 1701 Azure WebApp 개념원리
Saturday Azure Live 1701 Azure WebApp 개념원리Youngjae Kim
 
REST API Development with Spring
REST API Development with SpringREST API Development with Spring
REST API Development with SpringKeesun Baik
 
137 deview
137 deview137 deview
137 deviewNAVER D2
 
Popular Convention 개발기
Popular Convention 개발기Popular Convention 개발기
Popular Convention 개발기JeongHun Byeon
 
[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현
[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현
[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현NAVER Engineering
 
Open source engineering - 0.1
Open source engineering - 0.1Open source engineering - 0.1
Open source engineering - 0.1YoungSu Son
 
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요Ian Choi
 
효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017
효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017
효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017Amazon Web Services Korea
 
목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, Vue목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, VueGunhee Lee
 
Curie: Deep-linking & App-indexing based mobile search engine
Curie: Deep-linking & App-indexing based mobile search engineCurie: Deep-linking & App-indexing based mobile search engine
Curie: Deep-linking & App-indexing based mobile search engineWonkyung Lyu
 
코드로 인프라 관리하기 - 자동화 툴 소개
코드로 인프라 관리하기 - 자동화 툴 소개코드로 인프라 관리하기 - 자동화 툴 소개
코드로 인프라 관리하기 - 자동화 툴 소개태준 문
 
my activities before getting a job
my activities before getting a jobmy activities before getting a job
my activities before getting a jobDeo Kim
 

Similar to GDG Incheon Devfest 2016 - Google API로 만드는 더욱 더 풍부한 백오피스 (20)

소셜 네트워크 앱 개발
소셜 네트워크 앱 개발소셜 네트워크 앱 개발
소셜 네트워크 앱 개발
 
Google Cloud NEXT'17 정리
Google Cloud NEXT'17 정리Google Cloud NEXT'17 정리
Google Cloud NEXT'17 정리
 
[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)
[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)
[Td 2015]박애주의 office 365, 멀티플랫폼과 사랑에 빠지다(최한홍)
 
How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)How to make Successful Open APIs for Startups (2012)
How to make Successful Open APIs for Startups (2012)
 
Firebase for web (웹개발을 위한 파이어베이스) 2 Authentication
Firebase for web (웹개발을 위한 파이어베이스) 2 AuthenticationFirebase for web (웹개발을 위한 파이어베이스) 2 Authentication
Firebase for web (웹개발을 위한 파이어베이스) 2 Authentication
 
Portfolio
PortfolioPortfolio
Portfolio
 
[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드
[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드
[AIS 2018][Team Tools_Basic] Atlassian 제품 기반의 DevOps 구성 - 투씨드
 
Saturday Azure Live 1701 Azure WebApp 개념원리
Saturday Azure Live 1701 Azure WebApp 개념원리Saturday Azure Live 1701 Azure WebApp 개념원리
Saturday Azure Live 1701 Azure WebApp 개념원리
 
REST API Development with Spring
REST API Development with SpringREST API Development with Spring
REST API Development with Spring
 
137 deview
137 deview137 deview
137 deview
 
Popular Convention 개발기
Popular Convention 개발기Popular Convention 개발기
Popular Convention 개발기
 
[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현
[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현
[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현
 
Open source engineering - 0.1
Open source engineering - 0.1Open source engineering - 0.1
Open source engineering - 0.1
 
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요
디자인에 이어 코딩까지 AI가 프로그램 개발을 척척?: GitHub Copilot, 어디까지 알아보셨나요
 
효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017
효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017
효과적인 데브옵스를 위한 AWS 개발 도구 활용하기 - AWS Summit Seoul 2017
 
목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, Vue목적에 맞게 Angular, React, Vue
목적에 맞게 Angular, React, Vue
 
Curie: Deep-linking & App-indexing based mobile search engine
Curie: Deep-linking & App-indexing based mobile search engineCurie: Deep-linking & App-indexing based mobile search engine
Curie: Deep-linking & App-indexing based mobile search engine
 
코드로 인프라 관리하기 - 자동화 툴 소개
코드로 인프라 관리하기 - 자동화 툴 소개코드로 인프라 관리하기 - 자동화 툴 소개
코드로 인프라 관리하기 - 자동화 툴 소개
 
my activities before getting a job
my activities before getting a jobmy activities before getting a job
my activities before getting a job
 
Web2.0
Web2.0Web2.0
Web2.0
 

GDG Incheon Devfest 2016 - Google API로 만드는 더욱 더 풍부한 백오피스

  • 1. Google API로 만드는
 더욱 더 풍부한 백오피스 MooYeol Prescott Lee Software Engineer @ Law&Company
  • 2. 발표자 소개 • 이무열 • Software Engineer @ LawCompany • mooyoul@gmail.com • https://github.com/mooyoul • https://www.linkedin.com/ in/mooyoul
  • 3. Google API를 통해 더 풍부한 백오피스를 만드는 방법
  • 5. 인증 • 두 독립적인 웹앱이 존재한다고 가정 • 일반적인 사진 인화 웹사이트 (A) / 사진 공유 웹사이트 (B) • 나는 (A)을 만드는 개발자 • (B)에는 사진을 올릴 수 있는 API가 있음
 아이디/패스워드 조합의 인증만 가능한 상황 • 이번에 고객이 (B)에 올린 사진을 가져와 인화하는 기능을 추가하려고 함
  • 7. 인증 • 만약 내가 악의적인 목적을 가지고 사용자의 비밀 정보를 수 집한다면? • 유저 입장에서 신뢰할 수 없음 • 제 3자에게 비밀번호 노출 가능성 (하필 비밀번호가 공인 인증서 비밀번호라면?) • 읽는 권한만 필요한데 모든 권한이 들어오네? • 접근 제어가 불가능
  • 9. OAuth • 표준 • 사용자의 비밀 정보를 입력받을 필요 없이 안전하게 인증 수 행 • Content Provider
 컨텐츠 제공자, 이전 슬라이드의 사진 공유 웹사이트 (B) • Content Consumer
 컨텐츠 소비자, 이전 슬라이드의 사진 인화 웹사이트 (A)
  • 13. OAuth References • OAuth
 https://oauth.net/ • RFC5849 - The OAuth 1.0 Protocol
 https://tools.ietf.org/html/rfc5849 • RFC6749 - The OAuth 2.0 Authorization Framework
 https://tools.ietf.org/html/rfc6749 • Yahoo! Developer - OAuth Flow
 https://developer.yahoo.com/oauth/guide/images/ oauth_graph.gif
  • 15. Google Identity Platform • 사용자 인증이 필요한 API에 접근하거나, 사용자 리소스에 접근이 필요한 경우 사용자 인증이 필요하다 • OAuth2 기반 인증 제공 • 일반적인 3-legged 형태의 인증 뿐만 아니라 Service Account를 통해 2-legged (Server to Server)로도 인증 가 능
  • 16. 3-legged OAuth • OAuth로 인증을 수행하는 대부분의 플랫폼에서 사용하는 인증 방식 • e.g.) Google ID로 로그인
 => 3-legged OAuth • User Interaction 필요

  • 18. Service Account • Service Account는 가상의 Google ID를 생성하고,
 각 서비스에서 권한 위임을 통해 리소스 접근 • mooyoul@gmail.com 계정에서
 some-id@developer.gserviceaccount.com 라는 Service Account를 생성하더라도,
 some-id@developer.gserviceaccount.com 는 mooyoul@gmail.com 의 리소스에 접근 불가능 • 독립적인 계정이므로 서비스 계정에서 생성한 컨텐츠 (e.g. Spreadsheet 문서) 역시 공유하거나 소유권을 변경하지 않으 면 mooyoul@gmail.com 에서 접근 불가능
  • 21. Creating Service Account • Service Account 생성은 API Console에서 가능
 
 https:// console.developers.google.com/ permissions/serviceaccounts?hl=ko
  • 22. Obtaining Access Token • JSON Web Token (JWT) 생성
 base64_encoded_header.base64_encoded_claim_set.bas e64_encoded_signature • 생성한 JWT로 Access Token 요청 • Access Token 응답 처리
  • 24. vs
  • 25. with googleapi module (built-in JWT based auth)
  • 26.
  • 27. Identity Platform References • Google Identity Platform
 https://developers.google.com/identity/ • Google Identity Platform - OAuth 2.0 Overview
 https://developers.google.com/identity/protocols/OAuth2 • Google Identity Platform - OAuth 2.0 for Server-side Web Apps
 https://developers.google.com/identity/protocols/OAuth2WebServer • Google Identity Platform - OAuth 2.0 API Scopes
 https://developers.google.com/identity/protocols/googlescopes • Google Identity Platform - OAuth 2.0 for Service Accounts
 https://developers.google.com/identity/protocols/OAuth2ServiceAccount • Google Identity Platform - Application Default Credentials
 https://developers.google.com/identity/protocols/application-default-credentials • Google API Node.js Client Library - Using JWT Service Tokens
 https://github.com/google/google-api-nodejs-client/#using-jwt-service-tokens
  • 29. Spreadsheets를 만드는 방법 • Google Drive API를 사용해서 CSV 업로드 • Google Apps Script • Google Sheets API (구 Spreadsheets API)
  • 30. Spreadsheets via Apps Script • Drive API를 통해 CSV 업로드를 했더니… • 휴대폰번호 “01012341234” => 숫자로 인식해 1012341234로 자동 변환되는 문제 발생 • Sheets API v3에서 cell-based 로 데이터를 밀어넣으려 니… • batch API에서 자꾸 문제가 발생
  • 32.
  • 34. Sheets API v4 의 등장
  • 35.
  • 36. Spreadsheets via Apps Script 🚫🚫
  • 38. Sheets API를 언제 쓰지? • 백오피스에서 회원 목록 CSV/Excel 출력되게 해주세요 • 매일 XX시에 YY를 한 유저의 리스트를 엑셀로 저장해주세요 • XXX 이벤트가 발생하면 지정한 엑셀파일에 추가(append) 해 주세요 • 휴대폰 주소가 들어있는 엑셀파일 읽어서 문자 보내주세요 • 메일 주소가 들어있는 엑셀파일 읽어서 메일 보내주세요 • …
  • 39. Sheets API • Google Spreadsheets를 내 마음대로 • Spreadsheet 조회/생성/삭제
 - Drive API를 통해서도 가능 • Sheet 조회/생성/수정/삭제 • 시트 데이터 조회/추가/수정/삭제 (V3: Row-based & Cell-based, V4: A1 Notation) • 기능을 조합하면 templating도 가능 • formula 또한 기본 지원
  • 40. Sheets API • https://docs.google.com/spreadsheets/d/ SPREADSHEET_ID/edit?pli=1#gid=SHEET_ID • https://docs.google.com/spreadsheets/d/ 1s0bXZu6nf7l04TOunn4paiz0fJ2pMV2CK4WKyeo8L4Q/ edit?pli=1#gid=495715675 • Spreadsheet ID
 1s0bXZu6nf7l04TOunn4paiz0fJ2pMV2CK4WKyeo8L4Q • Sheet ID (V3: Worksheet ID)
 495715675
  • 41. A1 Notation • Sheet1!A1:B2
 Sheet1의 (첫번째 행, 첫번째 열)에서 (두번째 행, 두번째 열)까지의 모든 셀 • Sheet1!A:A 
 Sheet1의 첫번째 열의 모든 셀 • Sheet1!1:2
 Sheet1의 첫번째 행부터 두번째 행까지의 모든 셀 • Sheet1!A5:A
 Sheet1의 첫번째 열의 다섯번째 행부터 마지막 행까지의 모든 셀 • A1:B2
 스프레드시트 내 첫번째 시트 첫번째 행의 두 셀 • Sheet1
 Sheet1의 모든 셀
  • 43. Create spreadsheet ‘my awesome spreadsheet’ 라는 이름을 가진
 스프레드시트 생성
  • 45. Demo
  • 46. References • Google Sheets API Guide
 https://developers.google.com/sheets/guides/concepts • Google Sheets API - Reading & Writing Values
 https://developers.google.com/sheets/guides/values • Google Sheets API - REST Reference
 https://developers.google.com/sheets/reference/rest/
  • 48. GA Core Reporting API • Google Analytics Dashboard에서 보는 (거의 모든) 데이터를 가져올 수 있음 • 2016년 1월 1일 부터 오늘까지의 Users • 2016년 10월의 총 PV • 어제 /some-path/depth2 페이지에 방문한 User/PV 수 • 최근 7주간 awesome-event 이벤트 카테고리의
 일 이벤트 수 • 기간별 PV 비교 (10월 1주차 PV, 10월 2주차 PV…) • Segment, Cohort, … 기타 등등
  • 49. Metrics & Dimensions • 측정할 Metric과 Dimension은 미리 알아두면 좋음. 엄청 많기 때문에… • Dimensions & Metrics Explorer 참고해 어느정도 눈에 익혀두면 좋음, 사 내 마케팅 팀의 도움을 받는것도 좋은 방법
 https://developers.google.com/analytics/devguides/reporting/core/ dimsmets • 개발시 reporting api를 매번 호출하는 것보다
 Google Analytics Demos & Tools 에서 제공하는 Query Explorer를 사용 해 측정 대상 지표들을 점검하고 개발을 권장 (훨씬 더 빨리 개발할 수 있음)
 https://ga-dev-tools.appspot.com/query-explorer/ • 단, 위 Query Explorer는 Version 3 API 이므로 Request Payload는 Version 4 API와는 다른 것에 주의
  • 50. Demo
  • 51. References • Google Analytics Core Reporting API
 https://developers.google.com/analytics/devguides/reporting/core/v4/ • Google Analytics Core Reporting REST Reference
 https://developers.google.com/analytics/devguides/reporting/core/v4/rest/ v4/reports/batchGet • Google Analytics Dimensions & Metrics Explorer
 https://developers.google.com/analytics/devguides/reporting/core/dimsmets • Google Analytics Demos & Tools
 https://ga-dev-tools.appspot.com • Google Analytics Query Explorer
 https://ga-dev-tools.appspot.com/query-explorer/
  • 53. Calendar API • Google Calendar API 역시 Sheets API 와 비슷하게 제공되는 거의 모든 기능을 API로 제어할 수 있음 • 캘린더 리스트 조회 • 캘린더 내 일정 조회 • 특정 일정 조회 • 일정 추가 (반복되는 일정도 처리 가능) • Push Notification (to registered server)
  • 54. Demo
  • 56. Analytics Core Reporting API + Slack Webhook
  • 57. Core Reporting API + Calendar API
 PhantomJS + D3 + Slack Webhook
  • 58. Core Reporting API + Sheets API
  • 59. Q&A