Search code examples
javascriptoauthelectronappauthapple-musickit

Apple's javascript MusicKit API authorize in electron app


I wanted to make an electron app that uses Apple's MusicKitjs API. However, the authorize function opens another window. This causes problems with electron since each window is sandboxed. The authentication does not seem to be OAuth which rules out a tool like AppAuth-JS.

Any ideas on how to implement non-OAuth API authentication in electron?


Solution

  • The best answer I can come up with so far is to not use Electron. Use NW.js instead.

    There may be a way to make MusicKit.js work with Electron, but it will likely compromise security or require substantial effort.

    NW.js does not have the same problem since it is a single process framework. When authorizing the MusicKit instance, it pops up a 2nd window and allows the user to login as desired. However, NW.js does need proprietary codecs to play audio from MusicKit. I am using these prebuilts and it seems to work fine so far.