summaryrefslogtreecommitdiff
path: root/docs/preconfigured_servers.rst
blob: 41948c12872a57a26830be088f4771cdfd1acf02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Preconfigured all-in-one servers
================================

A pre configured server is an all-in-one endpoint serving a specific
class of application clients. As the individual endpoints, they depend
on the use of a :doc:`validator`. 

Once constructed they can be plugged into any of the available 
:doc:`decorators` or used on their own. For the latter case you
might be interested in looking at :doc:`endpoints`.

Construction is simple, only import your validator and you are good to go::

    from your_validator import your_validator
    
    from oauthlib.oauth2 import WebApplicationServer
    server - WebApplicationServer(your_validator)

If you prefer to construct tokens yourself you may pass a token generator::

    def your_token_generator(request):
        return 'a_custom_token' + request.client_id

    server - WebApplicationServer(your_validator, token_generator-your_token_generator)

.. autoclass:: oauthlib.oauth2.draft25.WebApplicationServer
    :members:

.. autoclass:: oauthlib.oauth2.draft25.MobileApplicationServer
    :members:

.. autoclass:: oauthlib.oauth2.draft25.LegacyApplicationServer
    :members:

.. autoclass:: oauthlib.oauth2.draft25.BackendApplicationServer
    :members: