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]¶
- get_access_token() str | None[source]¶
Method to return the current requests’ access_token.
- Returns:
Access token or None
- Return type:
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:
Added in version 1.2.
- 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:
Added in version 1.0.