API Reference¶
- oidc_provider_mock.init_app(app: Flask, *, require_client_registration: bool = False, require_nonce: bool = False, issue_refresh_token: bool = True, access_token_max_age: timedelta = datetime.timedelta(seconds=3600), user_claims: Sequence[User] = ())[source]¶
Add the OpenID provider and its endpoints to the flask
app.- Parameters:
require_client_registration (bool) – If false (the default) any client ID and secret can be used to authenticate with the token endpoint. If true, clients have to be registered using the OAuth 2.0 Dynamic Client Registration Protocol.
require_nonce (bool) – If true, the authorization request must include the nonce parameter to prevent replay attacks. If the parameter is not provided the authorization request will fail.
issue_refresh_token (bool) – If true (the default), the token endpoint response will include a refresh token.
access_token_max_age (timedelta) – Max age of access and ID token after which it expires.
user_claims (Sequence[User]) – Predefined users that can be authorized with one click.
- oidc_provider_mock.app(*, require_client_registration: bool = False, require_nonce: bool = False, issue_refresh_token: bool = True, access_token_max_age: timedelta = datetime.timedelta(seconds=3600), user_claims: Sequence[User] = ()) Flask[source]¶
Create a Flask app running the OpenID provider.
Call
app().run()(seeflask.Flask.run) to start the server.See
init_appfor documentation of parameters
- oidc_provider_mock.run_server_in_thread(port: int = 0, *, require_client_registration: bool = False, require_nonce: bool = False, issue_refresh_token: bool = True, access_token_max_age: timedelta = datetime.timedelta(seconds=3600), user_claims: Sequence[User] = ()) AbstractContextManager[BaseWSGIServer][source]¶
Run a OIDC provider server on a background thread.
The server is stopped when the context ends.
See
appfor documentation of parameters.>>> with run_server_in_thread(port=25432) as server: ... print(f"Server listening at http://localhost:{server.server_port}") Server listening at http://localhost:25432