Add oauth support #117

Closed
mfussenegger opened this Issue Jan 2, 2013 · 9 comments

Projects

None yet

5 participants

@mfussenegger

Are there any concrete plans already?
There are already some hints that this might be added in the future. I would like to help out a bit.

There is a wrapper around curl that does this. Maybe some parts of the implementation could be taken from it: http://packages.python.org/curlish/

t-8ch commented Jan 2, 2013

As httpie is powered by requests you may want to have a look at https://github.com/requests/requests-oauthlib.
See also http://docs.python-requests.org/en/latest/user/authentication/

seanrose commented Jan 3, 2013

Will this include both OAuth 1 and OAuth 2?

Owner

Ideally both. Do you know of a good overview of the most common ways oauth is used?

Perhaps the auth backends could be made pluggable, distributed in its own packages, and once installed they could be enabled via the config file.

Btw, there is an older fork that adds support for OAuth 1.0 2-legged. It's not directly usable, but it provides the intended UI for specifying the auth type, key, and secret:

http --auth-type=oauth1_2leg --auth=ConsumerKey:ConsumerSecret POST http://localhost:5000/protected?w=1

Actually I would like to focus on OAuth2 first as it is easier to implement.

Some example of different OAuth consumers can probably taken from the oauth.org repo:
https://github.com/gulopine/foauth.org/tree/master/services

I am not sure how we should handle the different providers. Either do it in a similar way as curlish (that is: provide configuration files. Spawn a http server for the callback and use the browser-web-flow to get the token. This will probably be required for OAuth1 anyway).

Or integrate the services directly in httpie.
E.g. have an API like

http --auth-type=oauth2 --oauth-service=github --get-token --scopes=["public_repos"] --client-id=... --client-secret=...

But having to patch and update httpie just to use another service provider doesn't seem too appealing.

Since HTTPie is built on top of requests, it might make sense to build OAuth 2 support into requests, which doesn't currently exist. They have an extension for OAuth 1 currently here: https://github.com/requests/requests-oauthlib

I've updated my fork for OAuth 1.0a https://github.com/akhenakh/httpie, as the patch is really small using requests-oauthlib can we integrate in httpie ?

Owner

@akhenakh Support for OAuth 1.0.a 2-legged is now provided by the httpie-oauth plugin (requires HTTPie master).

The plugin is meant to provide also 3-legged OAuth flow and OAuth 2 support later on, but will require more work.

@jkbr thanks for the update, you should fix the home page for httpie-oauth it says "pip install httpie-auth" !

Owner

@akhenakh good catch, fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment