on develop help sign in
fix example of installed application authorization
commit382f1123283b31513da137cd0e003679aae4e2e1 authorAleksey Makarov <aleksey.makarov@gmail.com> dateThu 15 Sep 2016, 19:50 (10 years ago) parent70143bf
1 file changed+11−12
gogol/src/Network/Google/Auth/InstalledApplication.hs+11−12
gogol/src/Network/Google/Auth/InstalledApplication.hs+11−12
@@ -55,23 +55,22 @@ import qualified Network.HTTP.Conduit as Client
5555-- > {-# LANGUAGE ScopedTypeVariables #-}
5656--
5757-- > import Data.Proxy (Proxy (..))
58+-- > import Data.Text as T
59+-- > import Data.Text.IO as T
5860-- > import System.Exit (exitFailure)
5961-- > import System.Info (os)
6062-- > import System.Process (rawSystem)
6163--
62−-- > import qualified Data.ByteString as BS
63−-- > import qualified Data.ByteString.Lazy.Char8 as LBS8
64−-- >
65−-- > redirectPrompt :: forall s. OAuthClient -> proxy s -> IO (OAuthCode s)
64+-- > redirectPrompt :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> IO (OAuthCode s)
6665-- > redirectPrompt c p = do
67−-- > let url = LBS8.unpack (formURL c (Proxy :: Proxy s))
68−-- > putStrLn $ "Opening URL " ++ url
69−-- > case os of
70−-- > "darwin" -> rawSystem "open" [url]
71−-- > "linux" -> rawSystem "xdg-open" [url]
72−-- > _ -> putStrLn "Unsupported OS" >> exitFailure
73−-- > putStrLn "Please input the authorisation code: "
74−-- > OAuthCode . LBS.fromStrict <$> BS.getLine
66+-- > let url = formURL c p
67+-- > T.putStrLn $ "Opening URL " `T.append` url
68+-- > _ <- case os of
69+-- > "darwin" -> rawSystem "open" [unpack url]
70+-- > "linux" -> rawSystem "xdg-open" [unpack url]
71+-- > _ -> T.putStrLn "Unsupported OS" >> exitFailure
72+-- > T.putStrLn "Please input the authorisation code: "
73+-- > OAuthCode <$> T.getLine
7574--
7675-- This ensures the scopes passed to 'formURL' and the type of 'OAuthCode' 's'
7776-- are correct.