def oauth_aware(self, method):
def setup_oauth(request_handler, *args, **kwargs):<EOL><INDENT>if self._in_error:<EOL><INDENT>self._display_error_message(request_handler)<EOL>return<EOL><DEDENT>user = users.get_current_user()<EOL>if not user:<EOL><INDENT>request_handler.redirect(users.create_login_url(<EOL>request_handler.request.uri))<EOL>return<EOL><DEDENT>self._create_flow(request_handler)<EOL>self.flow.params['<STR_LIT:state>'] = _build_state_value(request_handler,<EOL>user)<EOL>self.credentials = self._storage_class(<EOL>self._credentials_class, None,<EOL>self._credentials_property_name, user=user).get()<EOL>try:<EOL><INDENT>resp = method(request_handler, *args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>self.credentials = None<EOL><DEDENT>return resp<EOL><DEDENT>return setup_oauth<EOL>
Decorator that sets up for OAuth 2.0 dance, but doesn't do it.

        Does all the setup for the OAuth dance, but doesn't initiate it.
        This decorator is useful if you want to create a page that knows
        whether or not the user has granted access to this application.
        From within a method decorated with @oauth_aware the has_credentials()
        and authorize_url() methods can be called.

        Args:
            method: callable, to be decorated method of a webapp.RequestHandler
                    instance.