[Androidpublisher API] voidedpurchases 를 사용하여 인앱 결제 취소를 확인하여 인앱 사기를 방지하자!! - 2
이전 방식 처럼 한다면 매번 구글 계정으로 인증을 해야하는 문제가 있다.
콘솔이나 배치 시스템에서 인앱 결제 취소를 확인 하려면 뭔가 다른 방법으로 access_token을 획득 해야 한다.
토큰 요청시 grant_type을 refresh_token으로 하여 refresh_token으로 사용하면 구글 인증 없이 계속 갱신이 가능하다.
그러면 refresh_token은 어떻게 얻느냐?
구글 계정 인증시 최초 1회만 획득 할 수 있다. 그 이후에 인증을 하면 refresh_token 없이 access_token만 리턴 된다.
https://myaccount.google.com/u/0/permissions
구글에서 인증 계정으로 로그인 하고 위 링크로 접속하여 해당 서비스의 액세스 권한을 삭제하고
다시 https://accounts.google.com/o/oauth2/v2/auth 로 oauth 인증을 해보자 그러면 refresh_token을 반환할 것이다.
이후로 아래처럼 요청하면 인증 코드 없이 access_token을 갱신 할 수 있다.
https://accounts.google.com/o/oauth2/token
method=get
parameter
client_id=[입력]
client_secret=[입력]
grant_type=refresh_token
refresh_token=[위에서 받은거 입력]
ex)
https://accounts.google.com/o/oauth2/token?client_id=[입력]&client_secret=[입력]&grant_type=refresh_token&refresh_token=[입력]
댓글
댓글 쓰기