AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'

后端 未结 2 941
一生所求
一生所求 2021-02-14 23:21

Problem: I\'ve been using Python Script Samples by Google to upload the apk to Play Store and to get list of apps published via my account (list_apks.py and

2条回答
  •  被撕碎了的回忆
    2021-02-14 23:54

    Finally after so many days, I was able to find answer to it. It turns out that the class SignedJwtAssertionCredentials was removed from the oath2client python package in the 2.0.0 update. It was no more under oauth2client.client. The behaviour has been moved onto oauth2client.service_account.ServiceAccountCredentials.

    Following worked for me:

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

    Source:

    • SignedJwtAssertionCredentials has been removed: Why?

    • oauth2client-Release 2.0.0

提交回复
热议问题