diff --git a/flask_oauthlib/contrib/client/application.py b/flask_oauthlib/contrib/client/application.py index c933d70e..43936932 100644 --- a/flask_oauthlib/contrib/client/application.py +++ b/flask_oauthlib/contrib/client/application.py @@ -22,6 +22,7 @@ from .descriptor import OAuthProperty, WebSessionData from .structure import OAuth1Response, OAuth2Response from .exceptions import AccessTokenNotFound +from .signals import request_token_fetched __all__ = ['OAuth1Application', 'OAuth2Application'] @@ -179,9 +180,8 @@ def authorize(self, callback_uri, code=302): oauth = self.make_oauth_session(callback_uri=callback_uri) # fetches request token - oauth.fetch_request_token(self.request_token_url) - # TODO send signal and pass token here - # http://flask.pocoo.org/docs/0.10/signals/ + token = oauth.fetch_request_token(self.request_token_url) + request_token_fetched.send(self, response=OAuth1Response(token)) # TODO check oauth_callback_confirmed here # http://tools.ietf.org/html/rfc5849#section-2.1 diff --git a/flask_oauthlib/contrib/client/signals.py b/flask_oauthlib/contrib/client/signals.py new file mode 100644 index 00000000..13df6e33 --- /dev/null +++ b/flask_oauthlib/contrib/client/signals.py @@ -0,0 +1,6 @@ +from flask.signals import Namespace + +__all__ = ['request_token_fetched'] + +_signals = Namespace() +request_token_fetched = _signals.signal('request-token-fetched')