liblastfm-0.5.1: Lastfm API interface

Safe HaskellNone
LanguageHaskell2010

Network.Lastfm.Authentication

Contents

Description

Lastfm authentication procedure helpers

Basically, lastfm provides 3 ways to authenticate user:

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__")]))]))

Synopsis

Helpers

getToken :: Request f (APIKey -> Ready) Source

Get authorization token

getSession :: Request f (Token -> APIKey -> Sign) Source

Get session key

getMobileSession :: Request f (Username -> Password -> APIKey -> Sign) Source

Get session key

link :: Request f a -> String Source

Construct link user should follow to approve application