1

server-side call에서 client-side generated access token을 사용하여 chromewebstore/v1.1/userlicenses /에 사용자 라이센스를 확인할 수 있습니까? 확장 프로그램과 앱 엔진 프로젝트가 모두 동일한 Gmail 계정에 등록되었습니다. 내 웹 응용 프로그램 사용자가 내 확장 프로그램을 구입했는지 알 수 있어야합니다.구글 앱 엔진에서 크롬 웹 스토어 사용자 라이센스를 확인하십시오.

gapi.auth.authorize({ 
scope: [ 
"https://www.googleapis.com/auth/plus.me", 
"https://www.googleapis.com/auth/plus.login", 
"https://www.googleapis.com/auth/userinfo.email", 
"https://www.googleapis.com/auth/chromewebstore.readonly"].join(" "), 
client_id: "xxxxx" 
},() => gapi.client.myapi.check_payment().execute()) 

앱 엔진 코드

import os 
import urllib 
import endpoints 
import httplib2 
from oauth2client import client 
from protorpc import remote 
from protorpc.message_types import VoidMessage 

EXTENSION_ID = "xxxxx" # my extension id from Chrome Web Store Developer Dashboard 
API_KEY = "xxxxx" # api key from Google APIs Console 
CLIENT_ID = "xxxxx" # OAuth 2.0 client ID from Google APIs Console 
SCOPES = [endpoints.EMAIL_SCOPE] 


@endpoints.api(name="myapi", version="v1", allowed_client_ids=[CLIENT_ID], scopes=SCOPES) 
class MyApi(remote.Service): 

    @endpoints.method(VoidMessage, VoidMessage) 
    def check_payment(self, msg): 
     user = endpoints.get_current_user() 
     assert user is not None 
     if "HTTP_AUTHORIZATION" in os.environ: 
      (tokentype, token) = os.environ["HTTP_AUTHORIZATION"].split(" ") 
      credentials = client.AccessTokenCredentials(token, 'my-user-agent/1.0') 
      http = credentials.authorize(httplib2.Http()) 
      params = urllib.urlencode({"key": API_KEY}) 
      url = "https://www.googleapis.com/chromewebstore/v1.1/userlicenses/%s?%s" % (EXTENSION_ID, params) 
      response = http.request(url) 

(403 개) 상태로 응답 : { "도메인": "글로벌", "이유를": "금지", "메시지": "당신 돈 \ 't 되세요 앱 ID : xxxxx에 대한 라이선스 데이터에 대한 액세스 "

답변

1

그래, 그럴 수있는 방법은 없습니다. 이런 종류의 요청은 identity.getAuthToken이 발행 한 토큰으로 만 인증 할 수 있습니다.

관련 문제