def init_app(self, app):
        """
        Do setup that requires a Flask app.

        :param app: The application to initialize.
        :type app: Flask
        """
        secrets = self.load_secrets(app)
        self.client_secrets = list(secrets.values())[0]
        secrets_cache = DummySecretsCache(secrets)

        # Set some default configuration options
        app.config.setdefault('OIDC_SCOPES', ['openid', 'email'])
        app.config.setdefault('OIDC_GOOGLE_APPS_DOMAIN', None)
        app.config.setdefault('OIDC_ID_TOKEN_COOKIE_NAME', 'oidc_id_token')
        app.config.setdefault('OIDC_ID_TOKEN_COOKIE_PATH', '/')
        app.config.setdefault('OIDC_ID_TOKEN_COOKIE_TTL', 7 * 86400)  # 7 days
        # should ONLY be turned off for local debugging
        app.config.setdefault('OIDC_COOKIE_SECURE', True)
        app.config.setdefault('OIDC_VALID_ISSUERS',
                              (self.client_secrets.get('issuer') or
                               GOOGLE_ISSUERS))
        app.config.setdefault('OIDC_CLOCK_SKEW', 60)  # 1 minute
        app.config.setdefault('OIDC_REQUIRE_VERIFIED_EMAIL', False)
        app.config.setdefault('OIDC_OPENID_REALM', None)
        app.config.setdefault('OIDC_USER_INFO_ENABLED', True)
        app.config.setdefault('OIDC_CALLBACK_ROUTE', '/oidc_callback')
        app.config.setdefault('OVERWRITE_REDIRECT_URI', False)
        app.config.setdefault("OIDC_EXTRA_REQUEST_AUTH_PARAMS", {})
        # Configuration for resource servers
        app.config.setdefault('OIDC_RESOURCE_SERVER_ONLY', False)
        app.config.setdefault('OIDC_RESOURCE_CHECK_AUD', False)

        # We use client_secret_post, because that's what the Google
        # oauth2client library defaults to
        app.config.setdefault('OIDC_INTROSPECTION_AUTH_METHOD', 'client_secret_post')
        app.config.setdefault('OIDC_TOKEN_TYPE_HINT', 'access_token')

        if not 'openid' in app.config['OIDC_SCOPES']:
            raise ValueError('The value "openid" must be in the OIDC_SCOPES')

        # register callback route and cookie-setting decorator
        if not app.config['OIDC_RESOURCE_SERVER_ONLY']:
            app.route(app.config['OIDC_CALLBACK_ROUTE'])(self._oidc_callback)
            app.before_request(self._before_request)
            app.after_request(self._after_request)

        # Initialize oauth2client
        self.flow = flow_from_clientsecrets(
            app.config['OIDC_CLIENT_SECRETS'],
            scope=app.config['OIDC_SCOPES'],
            cache=secrets_cache)
        assert isinstance(self.flow, OAuth2WebServerFlow)

        # create signers using the Flask secret key
        self.extra_data_serializer = JSONWebSignatureSerializer(
            app.config['SECRET_KEY'], salt='flask-oidc-extra-data')
        self.cookie_serializer = JSONWebSignatureSerializer(
            app.config['SECRET_KEY'], salt='flask-oidc-cookie')

        try:
            self.credentials_store = app.config['OIDC_CREDENTIALS_STORE']
        except KeyError:
            pass
def init_app ( self , app ) : secrets = self . load_secrets ( app ) self . client_secrets = list ( secrets . values ( ) ) [ 0 ] secrets_cache = DummySecretsCache ( secrets ) app . config . setdefault ( 'OIDC_SCOPES' , [ 'openid' , 'email' ] ) app . config . setdefault ( 'OIDC_GOOGLE_APPS_DOMAIN' , None ) app . config . setdefault ( 'OIDC_ID_TOKEN_COOKIE_NAME' , 'oidc_id_token' ) app . config . setdefault ( 'OIDC_ID_TOKEN_COOKIE_PATH' , '/' ) app . config . setdefault ( 'OIDC_ID_TOKEN_COOKIE_TTL' , 7 * 86400 ) app . config . setdefault ( 'OIDC_COOKIE_SECURE' , True ) app . config . setdefault ( 'OIDC_VALID_ISSUERS' , ( self . client_secrets . get ( 'issuer' ) or GOOGLE_ISSUERS ) ) app . config . setdefault ( 'OIDC_CLOCK_SKEW' , 60 ) app . config . setdefault ( 'OIDC_REQUIRE_VERIFIED_EMAIL' , False ) app . config . setdefault ( 'OIDC_OPENID_REALM' , None ) app . config . setdefault ( 'OIDC_USER_INFO_ENABLED' , True ) app . config . setdefault ( 'OIDC_CALLBACK_ROUTE' , '/oidc_callback' ) app . config . setdefault ( 'OVERWRITE_REDIRECT_URI' , False ) app . config . setdefault ( "OIDC_EXTRA_REQUEST_AUTH_PARAMS" , { } ) app . config . setdefault ( 'OIDC_RESOURCE_SERVER_ONLY' , False ) app . config . setdefault ( 'OIDC_RESOURCE_CHECK_AUD' , False ) app . config . setdefault ( 'OIDC_INTROSPECTION_AUTH_METHOD' , 'client_secret_post' ) app . config . setdefault ( 'OIDC_TOKEN_TYPE_HINT' , 'access_token' ) if not 'openid' in app . config [ 'OIDC_SCOPES' ] : raise ValueError ( 'The value "openid" must be in the OIDC_SCOPES' ) if not app . config [ 'OIDC_RESOURCE_SERVER_ONLY' ] : app . route ( app . config [ 'OIDC_CALLBACK_ROUTE' ] ) ( self . _oidc_callback ) app . before_request ( self . _before_request ) app . after_request ( self . _after_request ) self . flow = flow_from_clientsecrets ( app . config [ 'OIDC_CLIENT_SECRETS' ] , scope = app . config [ 'OIDC_SCOPES' ] , cache = secrets_cache ) assert isinstance ( self . flow , OAuth2WebServerFlow ) self . extra_data_serializer = JSONWebSignatureSerializer ( app . config [ 'SECRET_KEY' ] , salt = 'flask-oidc-extra-data' ) self . cookie_serializer = JSONWebSignatureSerializer ( app . config [ 'SECRET_KEY' ] , salt = 'flask-oidc-cookie' ) try : self . credentials_store = app . config [ 'OIDC_CREDENTIALS_STORE' ] except KeyError : pass
Do setup that requires a Flask app.

        :param app: The application to initialize.
        :type app: Flask