GithubHelp home page GithubHelp logo

flex-development / adt-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 852 KB

Generate JSON Web Tokens to authenticate with the Apple Music API.

Home Page: https://adt-api.flexdevelopment.vercel.app

License: BSD 3-Clause "New" or "Revised" License

JavaScript 24.96% TypeScript 72.81% Shell 2.24%
apple apple-developers apple-developer-token jsonwebtoken jwt apple-music-api apple-music

adt-api's Introduction

Apple Developer Token API

Generate JSON Web Tokens for use with the Apple Music API

TypeScript tested with jest

Overview

Getting Started
Usage
Built With
Contributing
Deployment

Getting Started

The Apple Developer Token (ADT) API is a serverless REST API that can be used to generate JSON Web Tokens (JWTs) suitable for use with the Apple Music API.

For more information, see Getting Keys and Creating Tokens from the Apple Developer docs.

Usage

Create Developer Token

Generates a JSON Web Token (JWT) suitable for use with the Apple Music API.

  • URL: https://adt-api.flexdevelopment.vercel.app/token
  • Method: POST

Authentication

The ADT API uses Basic Authentication to retrieive the Musickit identifier and private key used to generate developer tokens.

Example

APPLE_MUSICKIT_PRIVATE_KEY='-----BEGIN PRIVATE
KEY-----\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
XX\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nXXX
+XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+XXXXX\nXXXXXX\n-----END PRIVATE KEY-----\n'
APPLE_MUSICKIT_PRIVATE_KEY_ID='XXXXXXXXXX'

Query Parameters

name type default required description
expiresIn number 15777000 false Token expiration time
team string true Apple Team ID

Notes

  • expiresIn must not exceed 15777000 (6 months in seconds)
  • team is a 10-character string that can be retrieved from your developer account
  • A NotAuthenticated error will be thrown if team is invalid

Sample Response

"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"

Documentation

Retrieve the ADT API documentation as a JSON object. Documentation follows OpenAPI Specification v3.0.0 standards.

  • URL: https://adt-api.flexdevelopment.vercel.app
  • Method: GET

Sample Response

{
  "openapi": "3.0.0",
  "info": {
    "title": "Apple Developer Token API",
    "description": "Generate JSON Web Tokens for use with the Apple Music API.",
    "termsOfService": "",
    "contact": {
      "name": "GitHub",
      "url": "https://github.com/flex-development/adt-api"
    },
    "license": {
      "name": "License - BSD 3 Clause",
      "url": "https://spdx.org/licenses/BSD-3-Clause.html"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "description": "Production",
      "url": "https://adt-api.flexdevelopment.vercel.app"
    },
    {
      "description": "Next",
      "url": "https://adt-api-git-next-flexdevelopment.vercel.app"
    }
  ],
  "tags": [],
  "paths": {
    "/token": {
      "post": {
        "summary": "Create an Apple Developer token",
        "description": "Generates a JSON Web Token (JWT) suitable for use with the Apple Music API.",
        "operationId": "token-post",
        "parameters": [
          {
            "name": "expiresIn",
            "in": "query",
            "description": "Expiration time of registered claim key in seconds. Must not exceed `15777000` (6 months in seconds)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "team",
            "in": "query",
            "description": "Apple Team ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AppleDeveloperToken"
                }
              }
            }
          },
          "400": {
            "description": "BadRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequest"
                }
              }
            }
          },
          "401": {
            "description": "NotAuthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotAuthenticated"
                }
              }
            }
          },
          "500": {
            "description": "GeneralError",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeneralError"
                }
              }
            }
          }
        },
        "security": ["BasicAuth"]
      }
    }
  },
  "components": {
    "schemas": {
      "AppleDeveloperToken": {
        "type": "string"
      },
      "BadRequest": {
        "type": "object",
        "properties": {
          "className": {
            "type": "string",
            "example": "bad-request"
          },
          "code": {
            "type": "integer",
            "example": 400
          },
          "data": {
            "type": "object",
            "example": {}
          },
          "errors": {
            "type": "object",
            "example": {}
          },
          "message": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "BadRequest"
          }
        }
      },
      "GeneralError": {
        "type": "object",
        "properties": {
          "className": {
            "type": "string",
            "example": "general-error"
          },
          "code": {
            "type": "integer",
            "example": 500
          },
          "data": {
            "type": "object",
            "example": {}
          },
          "errors": {
            "type": "object",
            "example": {}
          },
          "message": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "GeneralError"
          }
        }
      },
      "NotAuthenticated": {
        "type": "object",
        "properties": {
          "className": {
            "type": "string",
            "example": "not-authenticated"
          },
          "code": {
            "type": "integer",
            "example": 401
          },
          "data": {
            "type": "object",
            "example": {}
          },
          "errors": {
            "type": "object",
            "example": {}
          },
          "message": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "NotAuthenticated"
          }
        }
      },
      "NotImplemented": {
        "type": "object",
        "properties": {
          "className": {
            "type": "string",
            "example": "not-implemented"
          },
          "code": {
            "type": "integer",
            "example": 501
          },
          "data": {
            "type": "object",
            "example": {}
          },
          "errors": {
            "type": "object",
            "example": {}
          },
          "message": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "example": "NotImplemented"
          }
        }
      }
    },
    "securitySchemes": {
      "BasicAuth": {
        "description": "Musickit identifier and private key",
        "type": "http",
        "scheme": "basic"
      }
    }
  },
  "externalDocs": {
    "description": "Apple Developer Docs - Getting Keys and Creating Tokens",
    "url": "https://developer.apple.com/documentation/applemusicapi/getting_keys_and_creating_tokens"
  }
}

Errors

If an error is thrown, it will have the following shape:

{
  "name": "GeneralError",
  "message": "",
  "code": 500,
  "className": "general-error",
  "data": {},
  "errors": {}
}

Built With

  • Vercel - Hosting platform for serverless functions
  • jsonwebtoken - JSON Web Token implementation for Node.js

adt-api's People

Contributors

unicornware avatar

Watchers

 avatar  avatar  avatar

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.