https://developer.android.com/google/play/billing/gp-purchase-status-api.html
https://developers.google.com/android-publisher/v1_1/
위의 주소를 참고해 구글 서버에서 구매 상태를 가져오는 작업을 하고 있습니다.
이 작업은 안드로이드 장비(핸드폰, 태블릿)이 아닌 별도로 개발한 윈도우 서버에서 요청하려고 합니다.
그리고 테스트는 맥에서 진행을 하고 있습니다.
https://developers.google.com/android-publisher/authorization
먼저 위의 주소를 참조하여 API 콘솔 프로젝트를 생성했습니다.
1. https://code.google.com/apis/console/# 주소에 들어가 프로젝트 생성
2. 좌측 패널의 "서비스"에서 "구글 플레이 안드로이드 디벨로퍼 API" 를 "ON"으로 변경
3. 좌측 패널의 "API 엑세스"에서 "OAuth 2.0 클라이언트 아이디" 생성 시작
4. 아이디 생성 중 "어플리케이션 타입" 을 "설치된 어플리케이션" 선택
( 설명 중에 데스크탑에서 실행 이라는 내용이 있어서 선택했습니다. 윈도우 서버에서 작업할것이기 때문입니다.)
5. "설치된 어플리케이션 타입"에서 "Other" 를 선택하고 생성을 완료
( 안드로이드, 크롬 어플리케이션, iOS 등이 있지만 윈도우 서버이기 때문에 이것을 선택하였습니다. )
6. https://cloud.google.com/console#/project 에서 "Unspecified App-Project"라는 등록된 앱을 확인
위의 순서로 OAuth 2.0 아이디를 생성하였습니다.
크롬 주소창에
https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/androidpublisher&response_type=code&access_type=offline&redirect_uri=...&client_id=...
위의 부분을 작성한 뒤 해당 페이지로 이동하여 "앱 요청 권한"에 동의를 하고 코드를 얻어왔습니다.
맥의 터미널을 실행하고
curl -d "grant_type=authorization_code&code=...&client_id=...&client_secret=...&redirect_uri=urn:ietf:wg:oauth:2.0:oob" https://accounts.google.com/o/oauth2/token
이 명령어의 데이터를 작성하고 실행하여 "access_token, token_type, expire_in, refresh_token" 들을 얻어오는데에 성공했습니다.
크롬 주소창에서
https://www.googleapis.com/androidpublisher/v1.1/applications/packageName/inapp/productId/purchases/token
이 내용을 작성하고 실행하면
{
"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}
웹 페이지에 위의 문구만 출력되고 구매 정보를 얻어올 수가 없습니다.
구글 개발자 콘솔에는 로그인 되어있는 상태입니다.
위의 절차중에 제가 빠뜨리거나 실수 한 부분이 있는지 알고싶습니다.