I am using google-api-python-client-1.7.9
I found documentation for internalappsharingartifacts in this repo - - but I can't figure out how to use it. It seems like the method is missing on my version of the client.
File "scripts/app_sharing_upload.py", line 45, in main
aab_response = service.internalappsharingartifacts().uploadBundle(
AttributeError: 'Resource' object has no attribute 'internalappsharingartifacts'
Here is some of my code for reference:
service = build('androidpublisher', 'v3', http=http)
aab_response = service.internalappsharingartifacts().uploadBundle(
packageName=package_name,
media_body=aab_file,
media_mime_type=aab_file
).execute()
Apologies for the state of our documentation - you'll probably have an easier time reading it here
It looks like the method is uploadbundle instead of uploadBundle, but I'm not sure if that's what's causing the issue.
The following seems to work correctly for me:
from googeapiclient import discovery
service = discovery.build('androidpublisher', 'v3')
service.internalappsharingartifacts().uploadbundle(packageName='foo').execute()
Would you mind showing us a bit more of your code?
Thank you for the fast response @busunkim96 !
You're right - that's embarassing! It was a casing issue. Here is the entire script right now. It works in case anyone else would like to use it.
#!/usr/bin/env python
import sys
#required on OSX to prevent the default 'six' library from interfering with the needed newer package,
#as of the 1.4.1 google-api library
sys.path.insert(1, '/Library/Python/2.7/site-packages')
import argparse
from googleapiclient.discovery import build
import httplib2
from oauth2client import client
from oauth2client.service_account import ServiceAccountCredentials
argparser = argparse.ArgumentParser(add_help=False)
argparser.add_argument('service_account',
help="Service account used to upload APK to Google Play")
argparser.add_argument('package_name',
help='The package name. Example: com.android.sample')
argparser.add_argument('aab_file',
help='The path to the AAB file to upload.')
argparser.add_argument('key_file',
help='The path to the p12 key file.')
def main():
# Process flags and read their values.
flags = argparser.parse_args()
# Create an httplib2.Http object to handle our HTTP requests and authorize it
# with the Credentials. Note that the first parameter, service_account_name,
# is the Email address created for the Service account. It must be the email
# address associated with the key that was created.
credentials = ServiceAccountCredentials.from_p12_keyfile(
flags.service_account,
flags.key_file,
scopes=['https://www.googleapis.com/auth/androidpublisher'])
http = httplib2.Http()
http = credentials.authorize(http)
service = build('androidpublisher', 'v3', http=http)
package_name = flags.package_name
aab_file = flags.aab_file
try:
aab_response = service.internalappsharingartifacts().uploadbundle(
packageName=package_name,
media_body=aab_file,
media_mime_type="application/octet-stream"
).execute()
print 'Successfully uploaded AAB'
print aab_response
except client.AccessTokenRefreshError:
print ('The credentials have been revoked or expired, please re-run the '
'application to re-authorize')
if __name__ == '__main__':
main()
Setting media_mime_type to application/octet-stream seems to have helped. Success! Thank you.
I'll update the script in case anyone else wants to use it.
Most helpful comment
Setting
media_mime_typetoapplication/octet-streamseems to have helped. Success! Thank you.