问题描述
我正在尝试使用开发人员API将APK上传到Google Play。我有一个大多数都能正常工作的Python脚本,但是上载内容始终返回“请求“ APK大小太大”时的HttpError 403”错误。通过网络界面手动上传和发布应用程序没有问题。我在某处缺少设置吗?
这是我当前的脚本:
import argparse
from googleapiclient.discovery import build
import google_auth_httplib2
import httplib2
from oauth2client import client
from google.oauth2 import service_account
from google.auth.transport.requests import Request
import sys,os,socket
def main():
pathname = os.path.dirname(sys.argv[0])
fullpath = os.path.abspath(pathname)
ScopES = ['https://www.googleapis.com/auth/androidpublisher']
SERVICE_ACCOUNT_FILE = fullpath + '/authorization_data.json' # access keys json file
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE,scopes=ScopES)
credentials.refresh(Request())
print(credentials.token)
http = httplib2.Http(timeout=300)
http = google_auth_httplib2.AuthorizedHttp(credentials,http=http)
service = build('androidpublisher','v3',http=http)
package_name = 'com.company.app'
apk_file = 'upload/myapp.apk'
try:
print('creating edit')
edit_request = service.edits().insert(body={},packageName=package_name)
result = edit_request.execute()
edit_id = result['id']
print('id: ' + edit_id)
print('uploading apk')
apk_response = service.edits().apks().upload(
editId=edit_id,packageName=package_name,media_body=apk_file
).execute()
print('Version code %d has been uploaded' % apk_response['versionCode'])
print('committing edit')
commit_request = service.edits().commit(
editId=edit_id,packageName=package_name
).execute()
print('Edit "%s" has been committed' % commit_request['id'])
except client.AccesstokenRefreshError:
print('The credentials have been revoked or expired,please re-run the application to re-authorize')
if __name__ == '__main__':
main()
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)