Sho*_*uri 8 python android attributeerror oauth2client google-play-developer-api
问题:我一直在使用Google的Python脚本示例将apk上传到Play商店并获取通过我的帐户发布的应用列表(list_apks.py和upload_apk.py
).然而最近它开始打破.我试图通过这样做来更新类似的软件包google-api-python-client
,但它没有帮助.oath2client
pip install --update packagename
日志:
这个如果在列出apk的时候:
Determining latest version for my.package.name...
error 25-Feb-2016 06:30:52 Traceback (most recent call last):
error 25-Feb-2016 06:30:52 File "list_apks.py", line 80, in <module>
error 25-Feb-2016 06:30:52 main()
error 25-Feb-2016 06:30:52 File "list_apks.py", line 46, in main
error 25-Feb-2016 06:30:52 credentials = client.SignedJwtAssertionCredentials(
error 25-Feb-2016 06:30:52 AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'
build 25-Feb-2016 06:30:52 Found latest APK version:
build 25-Feb-2016 06:30:52 Generated new APK version: 1
Run Code Online (Sandbox Code Playgroud)
这是上传apk时:
25-Feb-2016 06:33:30 Uploading APK...
25-Feb-2016 06:33:30 Traceback (most recent call last):
25-Feb-2016 06:33:30 File "upload_apk.py", line 115, in <module>
25-Feb-2016 06:33:30 main(sys.argv)
25-Feb-2016 06:33:30 File "upload_apk.py", line 62, in main
25-Feb-2016 06:33:30 credentials = client.SignedJwtAssertionCredentials(
25-Feb-2016 06:33:30 AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'
Run Code Online (Sandbox Code Playgroud)
代码片段:
import argparse
from apiclient.discovery import build
import httplib2
from oauth2client import client
SERVICE_ACCOUNT_EMAIL = (
'myaccountemail.com')
# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('package_name',
help='The package name. Example: com.android.sample')
def main():
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
f = file('mykeyname.p12', 'rb')
key = f.read()
f.close()
# HERE IS THE EXCEPTION
credentials = client.SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
key,
scope='https://www.googleapis.com/auth/androidpublisher')
http = httplib2.Http()
http = credentials.authorize(http)
...
Run Code Online (Sandbox Code Playgroud)
我还能尝试什么?我很感激你的帮助.
Sho*_*uri 26
经过这么多天,我终于找到了答案.事实证明,该类SignedJwtAssertionCredentials
已oath2client
在2.0.0
更新中从python包中删除.它已经不复存在了oauth2client.client
.行为已移至oauth2client.service_account.ServiceAccountCredentials
.
以下为我工作:
import argparse
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import httplib2
from oauth2client import client
SERVICE_ACCOUNT_EMAIL = ('myaccountemail.com')
# Declare command-line flags.
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('package_name',
help='The package name. Example: com.android.sample')
def main():
key='mykeyname.p12'
scope = 'https://www.googleapis.com/auth/androidpublisher'
credentials = ServiceAccountCredentials.from_p12_keyfile(
SERVICE_ACCOUNT_EMAIL,
key,
scopes=[scope]
)
http = httplib2.Http()
http = credentials.authorize(http)
....
Run Code Online (Sandbox Code Playgroud)
资源:
归档时间: |
|
查看次数: |
3592 次 |
最近记录: |