| 1 |
Developer Interface |
| 2 |
=================== |
| 3 |
|
| 4 |
Consumers |
| 5 |
--------- |
| 6 |
|
| 7 |
.. currentmodule:: flask_dance.consumer |
| 8 |
|
| 9 |
An OAuth consumer is a website that allows users to log in with other websites |
| 10 |
(known as OAuth providers). Once a user has gone through the OAuth dance, the |
| 11 |
consumer website is allowed to interact with the provider website on behalf |
| 12 |
of the user. |
| 13 |
|
| 14 |
.. autoclass:: OAuth1ConsumerBlueprint(...) |
| 15 |
|
| 16 |
.. automethod:: __init__ |
| 17 |
|
| 18 |
.. attribute:: session |
| 19 |
|
| 20 |
An :class:`~requests_oauthlib.OAuth1Session` instance that |
| 21 |
automatically loads tokens for the OAuth provider from the token storage. |
| 22 |
This instance is automatically created the first time it is referenced |
| 23 |
for each request to your Flask application. |
| 24 |
|
| 25 |
.. autoattribute:: storage |
| 26 |
|
| 27 |
.. autoattribute:: token |
| 28 |
|
| 29 |
.. attribute:: config |
| 30 |
|
| 31 |
A special dictionary that holds information about the current state of |
| 32 |
the application, which the token storage can use to look up the correct OAuth |
| 33 |
token from storage. For example, in a multi-user system, where each user |
| 34 |
has their own OAuth token, information about which user is currently logged |
| 35 |
in for this request is stored in this dictionary. This dictionary is special |
| 36 |
because it automatically alerts the storage when any attribute in the |
| 37 |
dictionary is changed, so that the storage's caches are appropriately |
| 38 |
invalidated. |
| 39 |
|
| 40 |
.. attribute:: from_config |
| 41 |
|
| 42 |
A dictionary used to dynamically load variables from the |
| 43 |
:doc:`Flask application config <flask:config>` into the blueprint |
| 44 |
at the start of each request. To tell this blueprint to pull configuration |
| 45 |
from the app, set key-value pairs on this dict. Keys are the name of |
| 46 |
the local variable to set on the blueprint object, and values are the |
| 47 |
variable name in the Flask application config. |
| 48 |
Variable names can be a dotpath. For example:: |
| 49 |
|
| 50 |
blueprint.from_config["session.client_id"] = "GITHUB_OAUTH_CLIENT_ID" |
| 51 |
|
| 52 |
Which will cause this line to execute at the start of every request:: |
| 53 |
|
| 54 |
blueprint.session.client_id = app.config["GITHUB_OAUTH_CLIENT_ID"] |
| 55 |
|
| 56 |
.. autoclass:: OAuth2ConsumerBlueprint(...) |
| 57 |
|
| 58 |
.. automethod:: __init__ |
| 59 |
|
| 60 |
.. attribute:: session |
| 61 |
|
| 62 |
An :class:`~requests_oauthlib.OAuth2Session` instance that |
| 63 |
automatically loads tokens for the OAuth provider from the storage. |
| 64 |
This instance is automatically created the first time it is referenced |
| 65 |
for each request to your Flask application. |
| 66 |
|
| 67 |
.. autoattribute:: storage |
| 68 |
|
| 69 |
.. autoattribute:: token |
| 70 |
|
| 71 |
.. attribute:: config |
| 72 |
|
| 73 |
A special dictionary that holds information about the current state of |
| 74 |
the application, which the token storage can use to look up the correct OAuth |
| 75 |
token from storage. For example, in a multi-user system, where each user |
| 76 |
has their own OAuth token, information about which user is currently logged |
| 77 |
in for this request is stored in this dictionary. This dictionary is special |
| 78 |
because it automatically alerts the storage when any attribute in the |
| 79 |
dictionary is changed, so that the storage's caches are appropriately |
| 80 |
invalidated. |
| 81 |
|
| 82 |
.. attribute:: from_config |
| 83 |
|
| 84 |
A dictionary used to dynamically load variables from the |
| 85 |
:doc:`Flask application config <flask:config>` into the blueprint |
| 86 |
at the start of each request. To tell this blueprint to pull configuration |
| 87 |
from the app, set key-value pairs on this dict. Keys are the name of |
| 88 |
the local variable to set on the blueprint object, and values are the |
| 89 |
variable name in the Flask application config. |
| 90 |
Variable names can be a dotpath. For example:: |
| 91 |
|
| 92 |
blueprint.from_config["session.client_id"] = "GITHUB_OAUTH_CLIENT_ID" |
| 93 |
|
| 94 |
Which will cause this line to execute at the start of every request:: |
| 95 |
|
| 96 |
blueprint.session.client_id = app.config["GITHUB_OAUTH_CLIENT_ID"] |
| 97 |
|
| 98 |
Storages |
| 99 |
-------- |
| 100 |
|
| 101 |
.. autoclass:: flask_dance.consumer.storage.session.SessionStorage(...) |
| 102 |
:members: |
| 103 |
:special-members: |
| 104 |
|
| 105 |
|
| 106 |
.. autoclass:: flask_dance.consumer.storage.sqla.SQLAlchemyStorage(...) |
| 107 |
:members: |
| 108 |
:special-members: |
| 109 |
|
| 110 |
Sessions |
| 111 |
-------- |
| 112 |
|
| 113 |
.. autoclass:: flask_dance.consumer.requests.OAuth1Session |
| 114 |
:members: token, authorized, authorization_required |
| 115 |
|
| 116 |
.. autoclass:: flask_dance.consumer.requests.OAuth2Session |
| 117 |
:members: token, access_token, authorized, authorization_required |