diff --git a/README.rst b/README.rst index 762ef52..1338fea 100644 --- a/README.rst +++ b/README.rst @@ -1,20 +1,16 @@ -.. figure:: https://travis-ci.org/smartfile/client-python.png - :alt: Travis CI Status - :target: https://travis-ci.org/smartfile/client-python - A `SmartFile`_ Open Source project. `Read more`_ about how SmartFile uses and contributes to Open Source software. .. figure:: http://www.smartfile.com/images/logo.jpg :alt: SmartFile -Introduction +Summary ------------ This library includes two API clients. Each one represents one of the supported authentication methods. ``BasicClient`` is used for HTTP Basic authentication, -using an API key and password. ``OAuthClient`` is used for OAuth authentication, -using tokens. +using an API key and password. ``OAuthClient`` is used for OAuth (version 1) authentication, +using tokens, which will require user interaction to complete authentication with the API. Both clients provide a thin wrapper around an HTTP library, taking care of some of the mundane details for you. The intended use of this library is to refer to @@ -37,7 +33,7 @@ Or via source code / GitHub. :: - $ git clone https://github.com/smartfile/client-python.git smartfile + $ git clone https://github.com/kissync/smartfile-client-python.git smartfile $ cd smartfile $ python setup.py install @@ -47,7 +43,9 @@ and `PyPI `_. Usage ----- -Some of the details this library takes care of are. +Choose between Basic and OAuth authentication methods, then continue to use the SmartFile API. + +Some of the details this library takes care of are: * Encoding and decoding of parameters and return values. You deal with Python types only. @@ -56,12 +54,20 @@ Some of the details this library takes care of are. * Authentication. Provide the credentials that you obtained from SmartFile, and plug them into this library. It will take care of the details. -Authentication --------------- +Basic Authentication +-------------------- + +Three methods are supported for providing API credentials using basic authentication. -Three methods are supported for providing API credentials. +1. Parameters when instantiating the client. -1. Environment variables. + .. code:: python + + >>> from smartfile import BasicClient + >>> api = BasicClient('**********', '**********') + >>> api.get('/ping') + +2. Environment variables. Export your credentials via your environment. @@ -80,7 +86,7 @@ Three methods are supported for providing API credentials. >>> api = BasicClient() >>> api.get('/ping') -2. `netrc `_ file (not supported with OAuth). +3. `netrc `_ file (not supported with OAuth). You can place the following into ``~/.netrc``: @@ -110,13 +116,26 @@ Three methods are supported for providing API credentials. >>> api = BasicClient(netrcfile='/etc/smartfile.keys') >>> api.get('/ping') -3. Parameters when instantiating the client. - .. code:: python +OAuth Authentication +-------------------- - >>> from smartfile import BasicClient - >>> api = BasicClient('**********', '**********') - >>> api.get('/ping') +Authentication using OAuth authentication is bit more complicated, as it involves tokens and secrets. + +.. code:: python + + >>> from smartfile import OAuthClient + >>> api = OAuthClient('**********', '**********') + >>> # Be sure to only call each method once for each OAuth login + >>> # + >>> # This is the first step with the client, which should be left alone + >>> api.get_request_token() + >>> # Redirect users to the following URL: + >>> # print "In your browser, go to: " + api.get_authorization_url() + >>> # This example uses raw_input to get the verification from the console: + >>> client_verification = raw_input("What was the verification? :") + >>> api.get_access_token(None, client_verification) + >>> api.get('/ping') Calling endpoints ----------------- @@ -207,3 +226,10 @@ to poll the status of the task. .. _SmartFile: http://www.smartfile.com/ .. _Read more: http://www.smartfile.com/open-source.html + +A `SmartFile`_ Open Source project. `Read more`_ about how SmartFile +uses and contributes to Open Source software. + +.. figure:: https://travis-ci.org/smartfile/client-python.png + :alt: Travis CI Status + :target: https://travis-ci.org/smartfile/client-python