Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pbrisbin/authenticate-oauth-cli
CLI interface for authorizing OAuth2 applications
https://github.com/pbrisbin/authenticate-oauth-cli
Last synced: 10 days ago
JSON representation
CLI interface for authorizing OAuth2 applications
- Host: GitHub
- URL: https://github.com/pbrisbin/authenticate-oauth-cli
- Owner: pbrisbin
- License: mit
- Created: 2015-03-10T21:51:51.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-02T20:40:08.000Z (almost 10 years ago)
- Last Synced: 2024-11-09T07:47:29.420Z (2 months ago)
- Language: Haskell
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# authenticate-oauth-cli
CLI interface for authorizing OAuth2 applications via [authenticate-oauth][].
[authenticate-oauth]: https://hackage.haskell.org/package/authenticate-oauth
Your user will be presented with a URL to visit to authorize your application
and receive a PIN. Upon entering the correct PIN, your program receives control
again with a valid [`Credential`][].[`Credential`]: https://hackage.haskell.org/package/authenticate-oauth/docs/Web-Authenticate-OAuth.html#t:Credential
The `Credential` is cached on the file system (following [XDG][]), meaning
subsequent calls to `authorizeApp` will not prompt, instead returning the cached
`Credential` immediately.[xdg]: http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
## Installation
```
git clone https://github.com/pbrisbin/authenticate-oauth-cli
cd your-project
cabal sandbox add-source path/to/authenticate-oauth-cli
```## Usage
```haskell
{-# LANGUAGE OverloadedStrings #-}
module Example whereimport Control.Monad.IO.Class (liftIO)
import Network.HTTP.Conduit (httpLbs, parseUrl, withManager)
import Web.Authenticate.OAuth (OAuth(..), newOAuth, signOAuth)
import Web.Authenticate.OAuth.CLI (authorizeApp)main :: IO ()
main = withManager $ \m -> do
cred <- authorizeApp "example" oauth mrequest <- signOAuth oauth cred =<< parseUrl "https://api.service.com/path"
response <- httpLbs request m
liftIO $ print response
oauth :: OAuth
oauth = newOAuth
{ oauthConsumerKey = "abc123"
, oauthConsumerSecret = "abc123"
, oauthRequestUri = "https://api.service.com/oauth/token"
, oauthAccessTokenUri = "https://api.service.com/oauth/request_token"
, oauthAuthorizeUri = "https://api.service.com/oauth/authorize_token"
}
```## Status
Not released.
Only known to work with Twitter. Known *not* to work with GitHub because their
API requires a User Agent which authenticate-oauth does not send by default,
apparently.Cached `Credential`s expiring or otherwise becoming invalid is not handled
gracefully (or at all, really). You'll have to check for such a scenario
yourself, find and remove any cached file, and try again.