구글 드라이브를 Ghost 저장소로 이용

구글 드라이브를 Ghost 저장소로 이용
Photo by Mitchell Luo / Unsplash

Local Ghost를  AWS로 이전 - 6편

이 번 포스트에서 고스트의 이미지 저장소로 구글 드라이브를 사용하는 방법을 다루겠다.

Google drive와 ghost 연결

https://github.com/robincsamuel/ghost-google-drive 을 방문하면 구글 드라이브를 연결시키는 방법이 나와있다. npm을 이용하는 법과 git을 이용해서 설치하는 법이 있다. 여기서는 npm을 이용하는 법을 다루겠다.

1. ghost가 설치된 폴더에서 current라는 폴더로 이동하고 고스트용 구글 드라이브 스토리지 모듈을 설치.

cd current
npm install ghost-google-drive

2. root 폴더로 돌아가서 새 디렉토리를 생성.

mkdir content/adapters/storage

3. 조금 전에 설치한 모듈을 adapters쪽으로 복사

cp -vR current/node_modules/ghost-google-drive content/adapters/storage/ghost-google-driv

4. npm 설치 실행

cd content/adapters/storage/ghost-google-drive
npm install

5. root폴더에 있는 config.development.json에서 storage부분을 수정해준다.

"storage": {
  "active": "ghost-google-drive",
  "ghost-google-drive": {
    "key": {
            "private_key_id": "YOUR PRIVATE KEY ID",
            "private_key": "YOUR PRIVATE KEY",
            "client_email": "YOUR CLIENT EMAIL",
            "client_id": "YOUR CLIENT ID"
     }
  }
},

각 종 키값을 모르겠다면 아래의 가이드를 계속 읽길 바람.

Google credentials

구글 콘솔로 가서 credentials값을 생성 해보겠다.

  1. 맨 위에 있는 select a project 콤보박스 를 클릭 > 우측 상단의 new project > 프로젝트명 기입

2. Enable APIS and Services > Google Drive 검색 > Google Drive API 활성화

3. Create Credentials 버튼 > api from: web server > application data  선택 > OAuth 인증 과정은 skip > Service Account Key 선택 > role은 owner

4. key 생성을 위해 credentials > email 클릭 > KEYS > ADD KEY > JSON > CREATE 하면 json 파일을 다운로드 받을 수 있고 키값을 확인 할 수 있다.

서비스 계정으로 연결된 구글 드라이브는 일반적인 구글 드라이브 처럼 로그인해서 자료를 관리할 수 없다. 걱정말고 6편을참고 하시라.


참고

https://github.com/robincsamuel/ghost-google-drive
https://github.com/behoyh/google-drive-ui/tree/master