5

Problem: Ich habe Python Script Samples by Google wurde mit der apk auf Play Store laden und über mein Konto (list_apks.py und upload_apk.py) veröffentlichte Liste der Anwendungen zu bekommen. Aber in letzter Zeit fing es an zu brechen. Ich habe versucht, die Pakete wie google-api-python-client, oath2client usw. zu aktualisieren, indem Sie pip install --update packagename tun, aber es hat nicht geholfen.Attribute: ‚Modul‘ Objekt hat kein Attribut ‚SignedJwtAssertionCredentials‘

Logs:

Dieses wenn während Listing apk suchen:

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 

Dies wird beim Hochladen apk:

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

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' 

-Code Sniplet

Was kann ich sonst noch versuchen? Ich würde Ihre Hilfe schätzen.

Antwort

15

Endlich nach so vielen Tagen konnte ich die Antwort darauf finden. Es stellt sich heraus, dass die Klasse SignedJwtAssertionCredentials aus dem oath2client Python-Paket im 2.0.0 Update entfernt wurde. Es war nicht mehr unter oauth2client.client. Das Verhalten wurde auf oauth2client.service_account.ServiceAccountCredentials verschoben.

Folge für mich gearbeitet:

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

Quelle:

Verwandte Themen