Add Apple Music integration for now playing
This commit is contained in:
29
slices/admin/views/apple_music/index.rb
Normal file
29
slices/admin/views/apple_music/index.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
require "jwt"
|
||||
|
||||
module Admin
|
||||
module Views
|
||||
module AppleMusic
|
||||
class Index < Admin::View
|
||||
include Deps["settings"]
|
||||
|
||||
expose :developer_token do
|
||||
authentication_payload = {
|
||||
iss: settings.apple_music_team,
|
||||
iat: Time.now.to_i, # Issue date
|
||||
exp: Time.now.to_i + 3600 # Expiry of this token.
|
||||
}
|
||||
# The file we got from Apple
|
||||
apple_music_secret = File.read(File.join(Hanami.app.root, "config", "AuthKey_#{settings.apple_music_key}.p8"))
|
||||
private_key = OpenSSL::PKey::EC.new(apple_music_secret)
|
||||
|
||||
JWT.encode(
|
||||
authentication_payload,
|
||||
private_key,
|
||||
'ES256',
|
||||
kid: settings.apple_music_key
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user