View Source AppStore.Token (App Store v0.2.0)

A module to geenrate the signed token for API usage.

Please also check AppStore.Token.Server for a GenServer to cache

Summary

Functions

Generate the token for API Requests

Types

@type key() :: %{id: String.t(), pem: String.t()}

Functions

Link to this function

generate_token(issuer_id, bundle_id, key)

View Source
@spec generate_token(String.t(), String.t(), key()) ::
  {:error, atom() | keyword()} | {:ok, binary(), %{optional(binary()) => any()}}

Generate the token for API Requests

Official documentation: Generating Tokens for API Requests

Options

  • issuer_id: Your issuer ID from the Keys page in App Store Connect
  • bundle_id: Your app’s bundle ID
  • key: a map with the Key ID and Private key

Example

iex> AppStore.Token.generate_token(
  "57246542-96fe-1a63-e053-0824d011072a",
  "com.example.testbundleid2021",
  %{
    id: "2X9R4HXF34",
    pem: "-----BEGIN PRIVATE KEY----- ..."
  }
)
"eyJhbGciOiJFUzI1NiIsImtpZCI6IjJYOVI0SFhGMzQiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJhcHBzdG9yZWNvbm5lY3QtdjEiLCJiaWQiOiJjb20uZXhhbXBsZS50ZXN0YnVuZGxlaWQyMDIxIiwiZXhwIjoxNjI5NTA2MjQwLCJpYXQiOjE2Mjk1MDI3MDAsImlzcyI6IjU3MjQ2NTQyLTk2ZmUtMWE2My1lMDUzLTA4MjRkMDExMDcyYSIsIm5vbmNlIjoiMnFlaWc0a2wxOTQ0aHFhbmVzMDAwMGMxIn0.gYa_A7J6a6UAyBTAohf4gj28jT0k-OX1CW8cwsVGb4EewEm3owdsv6iWvzt7SutCndCBg5hPfNFWuZ0Au20HxA"