module Util.Authenticate where
import Flickr.Monad
import Util.Keys
import Flickr.Types
import Flickr.Auth
authenticateForWeb :: String -> FM (Maybe (URLString, FM AuthToken))
authenticateForWeb forPerm = do
x <- getAPIKey
case apiKind x of
"web" -> do
fr <- getFrob
u <- mkLoginURL (aFrob fr) forPerm
return (Just (u, getToken fr))
k -> do
liftIO $ putStrLn ("Unexpected API key 'kind': " ++ k ++ ", expected 'web'.")
return Nothing
authenticateForMobile :: String -> FM (Maybe (URLString, String -> FM AuthToken))
authenticateForMobile perm = do
x <- getAPIKey
case apiKind x of
"mobile" -> do
u <- getMobileAuthURL
return (Just (u, \ mt -> getFullToken mt))
k -> do
liftIO $ putStrLn ("Unexpected API key 'kind': " ++ k ++ ", expected 'mobile'.")
return Nothing