Giter Club home page Giter Club logo

asconnect's Introduction

asconnect

asconnect is a Python wrapper around the Apple App Store Connect REST APIs.

This wrapper does not cover every API, but does cover the basics, including:

  • Uploading a build
  • Creating a new TestFlight version
  • Setting TestFlight review information
  • Creating a new app store version
  • Setting the app review information
  • Submitting for app review

Getting Started

Installation

The package is available on PyPI, so you can run pip install asconnect to get the latest version.

Creating a client

To begin, you need to generate a key, then get it's ID, the contents of the key itself, and the issuer ID.

Once you have those, you can create a new client by running:

client = asconnect.Client(key_id="...", key_contents="...", issuer_id="...")

Getting your App

Most operations require an app identifier. This is not the same as the bundle ID you choose, but is an ID generated by Apple. The easiest way to get this is to run this code:

app = client.app.get_from_bundle_id("com.example.my_bundle_id")

Uploading a Build

Uploading a build isn't technically part of the App Store Connect APIs, but a wrapper around altool is included to make things as easy as possible. Let's upload a build for your app:

client.build.upload(
  ipa_path="/path/to/the/app.ipa",
  platform=asconnect.Platform.ios,
)

And if you want to wait for your build to finish processing:

build = client.build.wait_for_build_to_process("com.example.my_bundle_id", build_number)

build_number is the build number you gave your build when you created it. It's used by the app store to identify the build.

App Store Submission

Let's take that build, create a new app store version and submit it,

# Create a new version
version = client.app.create_new_version(version="1.2.3", app_id=app.identifier)

# Set the build for that version
client.version.set_build(version_id=version.identifier, build_id=build.identifier)

# Submit for review
client.version.submit_for_review(version_id=version.identifier)

It's that easy. Most of the time at least. If you don't have previous version to inherit information from you'll need to do things like set screenshots, reviewer info, etc. All of which is possible through this library.

Phased Distribution

# Create a new version
version = client.app.create_new_version(version="1.2.3", app_id=app.identifier)

# Start a versions' phased release, the initial state of which is INACTIVE
phased_release = client.version.create_phased_release(version_id=version.identifier)

# Check on a phased release
phased_release = client.version.get_phased_release(version_id=version.identifier)

# Advance or modify a phased release
phased_release = client.version.patch_phased_release(phased_release_id=phased_release.identifier, phased_release_state=PhasedReleaseState.active)
phased_release = client.version.patch_phased_release(phased_release_id=phased_release.identifier, phased_release_state=PhasedReleaseState.pause)
phased_release = client.version.patch_phased_release(phased_release_id=phased_release.identifier, phased_release_state=PhasedReleaseState.complete)

# Delete
client.version.delete_phased_release(phased_release_id=phased_release.identifier)

Getting Started

For development asconnect uses poetry

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

asconnect's People

Contributors

aaroncrespo avatar dalemyers avatar dependabot[bot] avatar fiannaca avatar guojiubo avatar microsoft-github-operations[bot] avatar microsoftopensource avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asconnect's Issues

Random 401 responses from the API

We've heard that the API occasionally responds with a 401 like:

[401] Authentication credentials are missing or invalid. (NOT_AUTHORIZED): Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests

Retrying works in these cases, so it's a transient issue on Apple's end. We've opened a radar for this, but can hopefully get something done in the mean time to help alleviate this issue.

crashing when upgrading PyJWT beyond 1.7.1

When I upgrade PyJWT to a more recent version, I get a crash in httpclient.py, line 138. It seems that the encode method now returns a string?

Is there something Im missing? this project says that it supports PyJWT < 3.0

Exception when parsing valid response from GET appInfos/{app_info_id}/appInfoLocalizations

I am encountering an exception when running the following test script:

client = asconnect.Client(key_id="****", key_contents="****", issuer_id="****")
app = client.app.get_from_bundle_id("****")

print("Connected to App Store Connect via API\n")
print("App: " + app.name + "\n")

info = client.app_info.get_app_info(app_id=app.identifier)

for item in info:
    print(item.identifier)

    # Exception occurs on the following line...
    localizations = client.app_info.get_localizations(app_info_id=item.identifier)

    for localization in localizations:
        print("\t" + localization.attributes.locale + ": " + localization.attributes.name)

Traceback of the exception:

Traceback (most recent call last):
  File "asconnect-test.py", line 20, in <module>
    for localization in localizations:
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/asconnect/app_info_client.py", line 63, in get_localizations
    yield from self.http_client.get(url=url, data_type=List[AppInfoLocalization])
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/asconnect/httpclient.py", line 126, in get
    deserialized_data = deserialize.deserialize(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 93, in deserialize
    return _deserialize(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 186, in _deserialize
    _deserialize_list(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 255, in _deserialize_list
    deserialized = _deserialize(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 175, in _deserialize
    _deserialize_dict(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 393, in _deserialize_dict
    deserialized_value = _deserialize(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 175, in _deserialize
    _deserialize_dict(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 393, in _deserialize_dict
    deserialized_value = _deserialize(
  File "/Users/alfianna/.local/share/virtualenvs/asconnect-test-xCg3XSFM/lib/python3.8/site-packages/deserialize/__init__.py", line 223, in _deserialize
    raise DeserializeException(
deserialize.exceptions.DeserializeException: Cannot deserialize '<class 'NoneType'>' to '<class 'str'>' for 'typing.List[asconnect.models.app_info.AppInfoLocalization][0].attributes.privacy_policy_text'

I'm running the following configuration:

  • asconnect 1.0.2
  • python 3.8
  • MacOS 10.15.6

I think this exception is occurring because AppInfoLocalization.Attributes.privacy_policy_text is of type str instead of Optional[str] in app_info.y:23. Looking at the API docs, I think all of the parameters of AppInfoLocalization.Attributes are optional.

I'll open a PR with a proposed fix momentarily.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.