amjwt

package module
v0.0.0-...-d8c97b6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 3 Imported by: 0

README

🍎🎵
AMJWT

An Apple Music JWT generator.

GitHub Workflow Status Go Report Card PkgGoDev

Usage

Pre-requisites

Before you can generate a JWT, you'll need a key id, team id, and private key file. Rather than re-explaining that process, he's Apples docs: https://developer.apple.com/documentation/applemusicapi/getting_keys_and_creating_tokens

Once you have those ready, you can use amjwt to generate the JWT.

As a CLI

amjwt can be used as a CLI. You can provide the key and team IDs via the -k and -t flags respectively. -f can be used to specify the path to the private key file.

amjwt -k <key-id> -t <team-id> -f ./MyPrivateKey.p8

You can also pipe the private key in if necessary:

cat ./MyPrivateKey.p8 | amjwt -k <key-id> -t <team-id>

As a Package

You can also import amjwt as a go package:

import "github.com/yukitsune/amjwt"
keyId := "foo"
teamId := "bar"
privateKeyBytes, err = ioutil.ReadFile("./somewhere/MyPrivateKey.p8")
jwtString, err := amjwt.CreateJwt(keyId, teamId, expiryDays, privateKeyBytes)

Contributing

Contributions are what make the open source community such an amazing place to be, learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (feature/AmazingFeature)
  3. Commit your Changes
  4. Push to the Branch
  5. Open a Pull Request

But... Why?

Because for some reason, Apple wants you to hand craft the JWT to authenticate with the Apple Music API. This is much easier than hand crafting it every time.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version defines the version of amjwt
	Version string
)

Functions

func CreateJwt

func CreateJwt(keyId string, teamId string, expiryDays int, privateKeyBytes []byte) (string, error)

CreateJwt will create the JWT and return it as a string

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL