Lomray-Software / react-native-apple-music

A react native module for the Apple Music SDK.
Apache License 2.0
19 stars 9 forks source link

How to get user token for apple music? #6

Closed deveshb-am closed 6 months ago

deveshb-am commented 8 months ago

I am using Auth.authorize() function but it only gives me status instead of giving me the user token, is there a way to get the token?

Pashkagreen commented 8 months ago

I am using Auth.authorize() function but it only gives me status instead of giving me the user token, is there a way to get the token?

Hi @deveshb-am, in order to use Apple MusicKit inside of your application, you have to enable MusicKit usage for your application in Apple Developer portal

Screenshot 2024-03-02 at 17 04 25

Please refer to official docs: https://developer.apple.com/documentation/musickit/using-automatic-token-generation-for-apple-music-api

Auth.authorize() will return you only a status, not a token. After you enable usage of MusicKit for your app and successfully authorizes (it means that your user has an AppleMusic application and active subscription on his device), you will be able to use all capabilities of AppleMusic & play music directly in your application. If you have any questions, let me know.

Pashkagreen commented 8 months ago

I am using Auth.authorize() function but it only gives me status instead of giving me the user token, is there a way to get the token?

There is an alternative way to communicate with Apple Music services via bearer token, but it mostly used for web applications. In this case, you will have to create a special service key in Apple developer portal, and then convert it on your node.js server in a bearer token. After that, you can start use it with https://developer.apple.com/documentation/musickitjs/adding_musickit_features_using_html

Screenshot 2024-03-02 at 17 26 02