Safe Haskell | None |
---|---|
Language | Haskell2010 |
Lastfm authentication procedure helpers
Basically, lastfm provides 3 ways to authenticate user:
- web application - http://www.last.fm/api/webauth
- desktop application - http://www.last.fm/api/desktopauth
- modile application - http://www.last.fm/api/mobileauth
Note that you can use any of them in your application despite their names
How to get session key for yourself for debug with GHCi:
>>>
import Network.Lastfm
>>>
import Network.Lastfm.Authentication
>>>
:set -XOverloadedStrings
>>>
con <- newConnection
>>>
lastfm con $ getToken <*> apiKey "__API_KEY__" <* json
Right (Object (fromList [("token",String "__TOKEN__")]))>>>
putStrLn . link $ apiKey "__API_KEY__" <* token "__TOKEN__"
http://www.last.fm/api/auth/?api_key=__API_KEY__&token=__TOKEN__>>>
-- Click that link ^^^
>>>
lastfm con $ sign "__SECRET__" $ getSession <*> token "__TOKEN__" <*> apiKey "__API_KEY__" <* json
Right (Object (fromList [("session",Object (fromList [("subscriber",String "0"),("key",String "__SESSION_KEY__"),("name",String "__USER__")]))]))