gpt4 book ai didi

android - AttributeError: 'module' 对象没有属性 'SignedJwtAssertionCredentials'

转载 作者:太空狗 更新时间:2023-10-29 21:14:40 24 4
gpt4 key购买 nike

问题:我一直在使用 Python Script Samples by Google将 apk 上传到 Play 商店并获取通过我的帐户发布的应用列表(list_apks.pyupload_apk.py)。但是最近它开始崩溃了。我尝试通过 pip install --update packagename 更新 google-api-python-clientoath2client 等包,但它没有帮助。

日志:

如果在列出 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

这是上传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'

代码 fragment :

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)
...

我还能尝试什么?非常感谢您的帮助。

最佳答案

经过这么多天,我终于找到了答案。事实证明,类 SignedJwtAssertionCredentials 已从 2.0.0 更新中的 oath2client 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)
....

来源:

关于android - AttributeError: 'module' 对象没有属性 'SignedJwtAssertionCredentials',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35634085/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com