diff --git a/gogol/src/Network/Google/Auth/InstalledApplication.hs b/gogol/src/Network/Google/Auth/InstalledApplication.hs index b8867af3af..2b1d0e3255 100644 --- a/gogol/src/Network/Google/Auth/InstalledApplication.hs +++ b/gogol/src/Network/Google/Auth/InstalledApplication.hs @@ -1,4 +1,6 @@ +{-# LANGUAGE KindSignatures #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE DataKinds #-} -- | -- Module : Network.Google.Auth.InstalledApplication @@ -32,6 +34,7 @@ module Network.Google.Auth.InstalledApplication import Control.Monad.Catch (MonadCatch) import Control.Monad.IO.Class (MonadIO) import qualified Data.Text.Encoding as Text +import GHC.TypeLits (Symbol) import Network.Google.Auth.Scope (AllowScopes (..), queryEncodeScopes) import Network.Google.Internal.Auth @@ -52,23 +55,22 @@ import qualified Network.HTTP.Conduit as Client -- > {-# LANGUAGE ScopedTypeVariables #-} -- -- > import Data.Proxy (Proxy (..)) +-- > import Data.Text as T +-- > import Data.Text.IO as T -- > import System.Exit (exitFailure) -- > import System.Info (os) -- > import System.Process (rawSystem) -- --- > import qualified Data.ByteString as BS --- > import qualified Data.ByteString.Lazy.Char8 as LBS8 --- > --- > redirectPrompt :: forall s. OAuthClient -> proxy s -> IO (OAuthCode s) +-- > redirectPrompt :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> IO (OAuthCode s) -- > redirectPrompt c p = do --- > let url = LBS8.unpack (formURL c (Proxy :: Proxy s)) --- > putStrLn $ "Opening URL " ++ url --- > case os of --- > "darwin" -> rawSystem "open" [url] --- > "linux" -> rawSystem "xdg-open" [url] --- > _ -> putStrLn "Unsupported OS" >> exitFailure --- > putStrLn "Please input the authorisation code: " --- > OAuthCode . LBS.fromStrict <$> BS.getLine +-- > let url = formURL c p +-- > T.putStrLn $ "Opening URL " `T.append` url +-- > _ <- case os of +-- > "darwin" -> rawSystem "open" [unpack url] +-- > "linux" -> rawSystem "xdg-open" [unpack url] +-- > _ -> T.putStrLn "Unsupported OS" >> exitFailure +-- > T.putStrLn "Please input the authorisation code: " +-- > OAuthCode <$> T.getLine -- -- This ensures the scopes passed to 'formURL' and the type of 'OAuthCode' 's' -- are correct. @@ -83,7 +85,7 @@ redirectURI = "urn:ietf:wg:oauth:2.0:oob" -- construct a URL that can be used to obtain the 'OAuthCode'. -- -- /See:/ . -formURL :: AllowScopes s => OAuthClient -> proxy s -> Text +formURL :: AllowScopes (s :: [Symbol]) => OAuthClient -> proxy s -> Text formURL c = formURLWith c . allowScopes -- | Form a URL using 'OAuthScope' values. diff --git a/gogol/src/Network/Google/Auth/ServiceAccount.hs b/gogol/src/Network/Google/Auth/ServiceAccount.hs index 08251d953b..8cee8fdba0 100644 --- a/gogol/src/Network/Google/Auth/ServiceAccount.hs +++ b/gogol/src/Network/Google/Auth/ServiceAccount.hs @@ -76,7 +76,7 @@ authorizedUserToken u r = refreshRequest $ <> "&refresh_token=" <> toQueryParam (fromMaybe (_userRefresh u) r) } --- | Obtain an 'OAuthToken' from @https://accounts.google.com/o/oauth2/token@ +-- | Obtain an 'OAuthToken' from @https://accounts.google.com/o/oauth2/v2/auth@ -- by signing and sending a JSON Web Token (JWT) using the supplied 'ServiceAccount'. serviceAccountToken :: (MonadIO m, MonadCatch m, AllowScopes s) => ServiceAccount diff --git a/gogol/src/Network/Google/Internal/Auth.hs b/gogol/src/Network/Google/Internal/Auth.hs index 47a0696fc8..e270967d3b 100644 --- a/gogol/src/Network/Google/Internal/Auth.hs +++ b/gogol/src/Network/Google/Internal/Auth.hs @@ -245,9 +245,9 @@ instance FromJSON RefreshError where <$> o .: "error" <*> o .:? "error_description" --- | @https://accounts.google.com/o/oauth2/token@. +-- | @https://accounts.google.com/o/oauth2/v2/auth@. accountsURL :: Text -accountsURL = "https://accounts.google.com/o/oauth2/token" +accountsURL = "https://accounts.google.com/o/oauth2/v2/auth" accountsRequest :: Client.Request accountsRequest = def @@ -256,7 +256,7 @@ accountsRequest = def , Client.secure = True , Client.checkStatus = \_ _ _ -> Nothing , Client.method = "POST" - , Client.path = "/o/oauth2/token" + , Client.path = "/o/oauth2/v2/auth" , Client.requestHeaders = [ (hContentType, "application/x-www-form-urlencoded") ]