flask_oidc package

class flask_oidc.OpenIDConnect(app: Flask | None = None, credentials_store: Any | None = None, http: Any | None = None, time: Any | None = None, urandom: Any | None = None, prefix: str | None = None)[source]

Bases: object

accept_token = <authlib.integrations.flask_oauth2.resource_protector.ResourceProtector object>
check_token_expiry() ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], ForwardRef('Headers') | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], int] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], int, ForwardRef('Headers') | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | ForwardRef('WSGIApplication') | None[source]
custom_callback(*args: Any, **kwargs: Any) None[source]
ensure_active_token(token: OAuth2Token) bool[source]
get_access_token() str | None[source]

Method to return the current requests’ access_token.

Returns:

Access token or None

Return type:

str

Added in version 1.2.

get_refresh_token() str | None[source]

Method to return the current requests’ refresh_token.

Returns:

Access token or None

Return type:

str

Added in version 1.2.

init_app(app: Flask, prefix: str | None = None) None[source]
load_secrets(app: Flask) dict[str, Any][source]
logout(return_to: str | None = None)[source]

Request the browser to please forget the cookie we set, to clear the current session.

Note that as described in [1], this will not log out in the case of a browser that doesn’t clear cookies when requested to, and the user could be automatically logged in when they hit any authenticated endpoint.

[1]: https://github.com/puiterwijk/flask-oidc/issues/5#issuecomment-86187023

Added in version 1.0.

redirect_to_auth_server(destination: str | None = None, customstate: Any | None = None)[source]

Redirect to the IdP.

Parameters:
  • destination (Url to return the client to if a custom handler is not used. Not available with custom callback.) – The page that the user was going to, before we noticed they weren’t logged in.

  • customstate – Ignored, left here for compatibility.

Returns:

A redirect response to start the login process.

require_login(view_func: Callable[[...], ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], ForwardRef('Headers') | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], int] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], int, ForwardRef('Headers') | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | ForwardRef('WSGIApplication')]) Callable[[...], ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], ForwardRef('Headers') | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], int] | tuple[ForwardRef('Response') | str | bytes | list[Any] | Mapping[str, Any] | Iterator[str] | Iterator[bytes] | AsyncIterable[str] | AsyncIterable[bytes], int, ForwardRef('Headers') | Mapping[str, str | list[str] | tuple[str, ...]] | Sequence[tuple[str, str | list[str] | tuple[str, ...]]]] | ForwardRef('WSGIApplication')][source]

Use this to decorate view functions that require a user to be logged in. If the user is not already logged in, they will be sent to the Provider to log in, after which they will be returned.

Added in version 1.0: This was check() before.

user_getfield(field: str, access_token: str | None = None) Any[source]

Request a single field of information about the user.

Parameters:

field (str) – The name of the field requested.

Returns:

The value of the field. Depending on the type, this may be a string, list, dict, or something else.

Return type:

object

Added in version 1.0.

user_getinfo(fields: list[str], access_token: str | None = None) dict[str, Any][source]
property user_loggedin: bool

Represents whether the user is currently logged in.

Returns:

Whether the user is logged in with Flask-OIDC.

Return type:

bool

Added in version 1.0.

Submodules