0

I am creating a django app that allows you to authenticate spotify and apple music to get a list of top tracks and artists. I have configured spotify perfectly and that is all set.

Apple Music is giving me a headache I have tried so many things and cant seem to get it working, right now I have a developer token from this code:

import datetime
import jwt


secret = """-----BEGIN PRIVATE KEY-----
fakekey#####
-----END PRIVATE KEY-----"""
keyId = "blah"
teamId = "blah"
alg = 'ES256'

time_now = datetime.datetime.now()
time_expired = datetime.datetime.now() + datetime.timedelta(hours=12)

headers = {
    "alg": alg,
    "kid": keyId
}

payload = {
    "iss": teamId,
    "exp": int(time_expired.timestamp()),
    "iat": int(time_now.timestamp())
}


if __name__ == "__main__":
    """Create an auth token"""
    token = jwt.encode(payload, secret, algorithm=alg, headers=headers)

    print ("----TOKEN----")
    print(token)

    print ("----CURL----")
    print ("curl -v -H 'Authorization: Bearer %s' \"https://api.music.apple.com/v1/catalog/us/artists/36954\" " % (token))

With this developer token, where do I go from here? I cannot figure out how to get a users music library with this. I have tried oauth and sign in with apple and musickit js framework but no luck, someone can guide me in the right direction I hope? Thank you.

0 Answers0