def download_object(bucket, obj, out_file, encryption_key, key_hash):
 service = create_service()
 request = service.objects().get_media(bucket=bucket, object=obj)
 request.headers['x-goog-encryption-algorithm'] = 'AES256'
 request.headers['x-goog-encryption-key'] = encryption_key
 request.headers['x-goog-encryption-key-sha256'] = key_hash
 out_file.write(request.execute())

def download_object ( bucket , obj , out_file , encryption_key , key_hash ) : service = create_service ( ) request = service . objects ( ) . get_media ( bucket = bucket , object = obj ) request . headers [ 'x-goog-encryption-algorithm' ] = 'AES256' request . headers [ 'x-goog-encryption-key' ] = encryption_key request . headers [ 'x-goog-encryption-key-sha256' ] = key_hash out_file . write ( request . execute ( ) )
downloads an object protected by a custom encryption key .