티스토리 뷰

반응형

테스트 코드를 제대로 공부하고 싶어서 예제 프로젝트를 진행중이다

아직 유닛테스팅도 잘 작성하지 못하지만 TDD 어떤지 너무 궁금해서 해보기로 했다 :-) 

띄엄띄엄 조금조금 공부중인데 흐름을 놓치지 않도록 잘 정리해서 기록해두자 

 

주제는 Apple Music API를 이용한 토이 프로젝트...!!! 

Apple Music API는 이렇게 모든 API마다 response json을 친절하게 알려주는데, 이 json을 dummy data로 쓰기에 딱 좋기 때문이다 

 

https://developer.apple.com/documentation/applemusicapi/get_a_catalog_artist

 

 

일단 Apple Music API를 사용하기 위해서는 developer token이 필요하다 

이 순서대로 차근차근 해서 keyID, teamID 를 알아내고 나의 private key가 담긴 .p8 file을 얻어내야한다

https://developer.apple.com/documentation/applemusicapi/getting_keys_and_creating_tokens 

 

Getting Keys and Creating Tokens | Apple Developer Documentation

Article Getting Keys and Creating Tokens Obtain developer tokens and keys needed to make requests to the Apple Music API. OverviewTo make requests to the Apple Music API, Create a MusicKit identifier and private key using a developer token to authenticate

developer.apple.com

 

그리고 이 세가지를 조합해서 토큰을 구해야하는데 그 로직은 여기 밑의 파이썬 코드를 돌려서 얻어낸다 (험난하당...하지만 저 더미 json을 쓰기 위해 인내심을 가지고 해야한다)

https://github.com/pelauimagineering/apple-music-token-generator

 

pelauimagineering/apple-music-token-generator

Contribute to pelauimagineering/apple-music-token-generator development by creating an account on GitHub.

github.com

 

이렇게 해서 토큰을 얻어냈으면 프로젝트를 세팅해보자 --!! 

 

APIType이란 enum을 만들고 API request에 필요한 것들을 작성해준다 

( 외부 라이브러리를 안쓰고 진행해보고 싶어서 방대해짐.... urlComponet로 파라미터 추가하는 코드를 작성하며 Almaofire에게 감사함을 느낀다 

 

 

그리고 Artist API와 Rating API를 사용해볼 것이기 때문에 ArtistAPIType과 RatingAPIType를 만들어준다 :) 

 

 

반응형
댓글