Skip to content

Commit 0b12b68

Browse files
committed
Changes in docs
1 parent 893b03c commit 0b12b68

File tree

2 files changed

+18
-43
lines changed

2 files changed

+18
-43
lines changed

docs/additional.rst

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,39 @@ And you can also modify the response with after_request::
3737
Bindings
3838
--------
3939

40+
.. versionchanged:: 0.4
41+
42+
.. module:: flask_oauthlib.contrib.oauth2
43+
4044
Bindings are objects you can use to configure flask-oauthlib for use with
4145
various data stores. They allow you to define the required getters and setters
4246
for each data store with little effort.
4347

4448
SQLAlchemy OAuth2
4549
`````````````````
4650

47-
:class:`SQLAlchemyBinding` sets up getters and setters for storing the user,
51+
:meth:`bind_sqlalchemy` sets up getters and setters for storing the user,
4852
client, token and grant with SQLAlchemy, with some sane defaults. To use this
4953
class you'll need to create a SQLAlchemy model for each object. You can find
5054
examples of how to setup your SQLAlchemy models here: ref:`oauth2`.
5155

5256
You'll also need to provide another function which returns the currently
5357
logged-in user.
5458

55-
An example of how to use :class:`SQLAlchemyBinding`::
59+
An example of how to use :meth:`bind_sqlalchemy`::
5660

5761
oauth = OAuth2Provider(app)
5862

59-
SQLAlchemyBinding(oauth, db.session, user=User, client=Client,
60-
token=Token, grant=Grant, current_user=current_user)
63+
bind_sqlalchemy(oauth, db.session, user=User, client=Client,
64+
token=Token, grant=Grant, current_user=current_user)
6165

6266
Any of the classes can be omitted if you wish to register the getters and
6367
setters yourself::
6468

6569
oauth = OAuth2Provider(app)
6670

67-
SQLAlchemyBinding(oauth, db.session, user=User, client=Client,
68-
token=Token)
71+
bind_sqlalchemy(oauth, db.session, user=User, client=Client,
72+
token=Token)
6973

7074
@oauth.grantgetter
7175
def get_grant(client_id, code):
@@ -92,49 +96,22 @@ Grant Cache
9296

9397
Since the life of a Grant token is very short (usually about 100 seconds),
9498
storing it in a relational database is inefficient.
95-
The :class:`GrantCacheBinding` allows you to more efficiently cache the grant
99+
The :meth:`bind_cache_grant` allows you to more efficiently cache the grant
96100
token using Memcache, Redis, or some other caching system.
97101

98102
An example::
99103

100104
oauth = OAuth2Provider(app)
101-
config = {'OAUTH2_CACHE_TYPE': 'redis'}
105+
app.config.update({'OAUTH2_CACHE_TYPE': 'redis'})
102106

103-
GrantCacheBinding(app, oauth, current_user, config=config)
107+
bind_cache_grant(app, oauth, current_user)
104108

105109
- `app`: flask application
106110
- `oauth`: OAuth2Provider instance
107111
- `current_user`: a function that returns the current user
108-
- `config`: Any extra configuration
109112

110-
The configuration options are described below. The :class:`GrantCacheBinding`
113+
The configuration options are described below. The :meth:`bind_cache_grant`
111114
will use the configuration options from `Flask-Cache` if they are set, else it
112115
will set them to the following defaults. Any configuration specific to
113-
:class:`GrantCacheBinding` will take precedence over any `Flask-Cache`
116+
:meth:`bind_cache_grant` will take precedence over any `Flask-Cache`
114117
configuration that has been set.
115-
116-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
117-
| **Option** | **Description** | **Flask-Cache Default** | **Default** |
118-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
119-
| **OAUTH2_CACHE_DEFAULT_TIMEOUT** | The default timeout that is used. A grant token expires after this length of time. | CACHE_DEFAULT_TIMEOUT | 100s |
120-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
121-
| **OAUTH2_CACHE_THRESHOLD** | The maximum number of items the cache stores before it starts deleting some | CACHE_THRESHOLD | 500s |
122-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
123-
| **OAUTH2_CACHE_KEY_PREFIX** | A prefix that is added before all keys | CACHE_KEY_PREFIX | None |
124-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
125-
| **OAUTH2_CACHE_MEMCACHED_SERVERS** | A list or tuple of server addresses or alternatively a :class:`memcache.Client` or a compatible client | CACHE_MEMCACHED_SERVERS | None |
126-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
127-
| **OAUTH2_CACHE_REDIS_HOST** | Address of the Redis server or an object which API is compatible with the official Python Redis client (redis-py) | CACHE_REDIS_HOST | localhost |
128-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
129-
| **OAUTH2_CACHE_REDIS_PORT** | Port number on which Redis server listens for connections | CACHE_REDIS_PORT | 6379 |
130-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
131-
| **OAUTH2_CACHE_REDIS_PASSWORD** | Password authentication for the Redis server | CACHE_REDIS_PASSWORD | None |
132-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
133-
| **OAUTH2_CACHE_REDIS_DB** | Database (zero-based numeric index) on Redis Server to connect | CACHE_REDIS_DB | 0 |
134-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
135-
| **OAUTH2_CACHE_DIR** | The directory where cache files are stored | CACHE_DIR | None |
136-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
137-
| **OAUTH2_CACHE_MODE** | The file mode wanted for the cache files | CACHE_MODE | 0600 |
138-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+
139-
| **OAUTH2_CACHE_TYPE** | The cache system to be used (null, simple, redis, memcache, filesystem) | CACHE_TYPE | null |
140-
+------------------------------------+-------------------------------------------------------------------------------------------------------------------+-------------------------+-------------+

docs/api.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,8 @@ Contrib Reference
5151

5252
Here are APIs provided by contributors.
5353

54-
.. module:: flask_oauthlib.contrib.bindings
54+
.. module:: flask_oauthlib.contrib.oauth2
5555

56-
.. autoclass:: SQLAlchemyBinding
57-
:members:
56+
.. autofunction:: bind_sqlalchemy
5857

59-
.. autoclass:: GrantCacheBinding
60-
:members:
58+
.. autofunction:: bind_cache_grant

0 commit comments

Comments
 (0)