Last active
August 29, 2015 14:13
-
-
Save tvh/f888012114dda0be9165 to your computer and use it in GitHub Desktop.
Password OAuth2 Token
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | Request (via POST method) "Access Token" using Resource Owner Password Credentials Grant. | |
-- | |
-- | |
fetchAccessTokenPass :: Manager -- ^ HTTP connection manager | |
-> OAuth2 -- ^ OAuth Data | |
-> BS.ByteString -- ^ username | |
-> BS.ByteString -- ^ password | |
-> IO (OAuth2Result AccessToken) -- ^ Access Token | |
fetchAccessTokenPass manager oa username password = doJSONPostRequest manager oa uri body | |
where (uri, body) = accessTokenUrlPass oa username password | |
accessTokenUrlPass :: OAuth2 | |
-> BS.ByteString -- ^ username | |
-> BS.ByteString -- ^ password | |
-> (URI, PostBody) -- ^ access token request URL plus the request body. | |
accessTokenUrlPass oa username password = (uri, body) | |
where uri = oauthAccessTokenEndpoint oa | |
body = transform' [ ("client_id", Just $ oauthClientId oa) | |
, ("client_secret", Just $ oauthClientSecret oa) | |
, ("username", Just username) | |
, ("password", Just password) | |
, ("redirect_uri", oauthCallback oa) | |
, ("grant_type", Just "password")] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment