Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.Google.OAuth2
- data Credentials = Credentials {}
- data OAuth2Client = OAuth2Client {
- clientId :: !String
- clientSecret :: !String
- type OAuth2Code = String
- type OAuth2Scope = String
- type OAuth2Token = String
- data OAuth2Tokens = OAuth2Tokens {
- accessToken :: !OAuth2Token
- refreshToken :: !OAuth2Token
- expiresIn :: !Int
- tokenType :: !String
- getAccessToken :: OAuth2Client -> [OAuth2Scope] -> Maybe FilePath -> IO OAuth2Token
- newCreds :: OAuth2Client -> [OAuth2Scope] -> IO Credentials
- refreshCreds :: Credentials -> IO Credentials
- promptForCode :: OAuth2Client -> [OAuth2Scope] -> IO OAuth2Code
- exchangeCode :: OAuth2Client -> OAuth2Code -> IO OAuth2Tokens
Types
data Credentials Source
Pairs a client and its tokens
This type is primarily so they can be cached together and not require access the client id when using cached tokens
Constructors
Credentials | |
Fields |
Instances
data OAuth2Client Source
OAuth2 client definition
https://developers.google.com/console/help/new/#generatingoauth2
Constructors
OAuth2Client | |
Fields
|
Instances
type OAuth2Code = String Source
type OAuth2Scope = String Source
type OAuth2Token = String Source
data OAuth2Tokens Source
Constructors
OAuth2Tokens | |
Fields
|
Instances
Getting an access token
Arguments
:: OAuth2Client | |
-> [OAuth2Scope] | |
-> Maybe FilePath | File in which to cache the token |
-> IO OAuth2Token | Refreshed token |
Get a valid access token with the given scopes
If given, credentials are cached in a file, thus preventing the need for any prompting on subsequent reuse. N.B. this function always refreshes the access token before returning it.
Lower-level steps
newCreds :: OAuth2Client -> [OAuth2Scope] -> IO Credentials Source
Prompt the user for a verification code and exchange it for tokens
refreshCreds :: Credentials -> IO Credentials Source
Use the refresh token to get a new access token
promptForCode :: OAuth2Client -> [OAuth2Scope] -> IO OAuth2Code Source
Prompt the user for a verification code
exchangeCode :: OAuth2Client -> OAuth2Code -> IO OAuth2Tokens Source
Exchange a verification code for tokens