\n confirm\n
\n\n deny\n
\n \n '''\n\n def authenticate(self, request, environ, scopes, client):\n # Check if the user has granted access\n if request.post_param(\"confirm\") == \"confirm\":\n return {}\n\n raise oauth2.error.UserNotAuthenticated\n\n def render_auth_page(self, request, response, environ, scopes,\n client):\n url = request.path + \"?\" + request.query_string\n response.body = self.TEMPLATE.format(url=url)\n return response\n\n def user_has_denied_access(self, request):\n # Check if the user has denied access\n if request.post_param(\"deny\") == \"deny\":\n return True\n return False\n\n # Create an in-memory storage to store your client apps.\n client_store = oauth2.store.memory.ClientStore()\n # Add a client\n client_store.add_client(client_id=\"abc\", client_secret=\"xyz\",\n redirect_uris=[\"http://localhost/callback\"])\n\n site_adapter = ExampleSiteAdapter()\n\n # Create an in-memory storage to store issued tokens.\n # LocalTokenStore can store access and auth tokens\n token_store = oauth2.store.memory.TokenStore()\n\n # Create the controller.\n provider = oauth2.Provider(\n access_token_store=token_store,\n auth_code_store=token_store,\n client_store=client_store,\n token_generator=oauth2.tokengenerator.Uuid4()\n )\n\n # Add Grants you want to support\n provider.add_grant(oauth2.grant.AuthorizationCodeGrant(site_adapter=site_adapter))\n provider.add_grant(oauth2.grant.ImplicitGrant(site_adapter=site_adapter))\n\n # Add refresh token capability and set expiration time of access tokens\n # to 30 days\n provider.add_grant(oauth2.grant.RefreshToken(expires_in=2592000))\n\n # Wrap the controller with the Wsgi adapter\n app = oauth2.web.wsgi.Application(provider=provider)\n\n if __name__ == \"__main__\":\n httpd = make_server('', 8080, app)\n httpd.serve_forever()\n\n\nThis example only shows how to instantiate the server.\nIt is not a working example as a client app is missing. Take a look at the\n`examples