Core functionality

This module defines the Flask extension.

class flask_ipernity.Ipernity(app: Flask | None = None)[source]

Bases: object

Class for the Flask Extension.

Parameters:

app – The Flask application

authorize(permissions: Mapping[str, str] | None = None, next_url: str | None = None) Response[source]

Returns a redirect to the authorization URL.

Creates an authorization URL on www.ipernity.com for the requested permissions with auth_url and redirects there. Ipernity then checks if these permissions have already been authorized and asks the user if not. After authorization, the user is redirected back to the application’s callback.

Parameters:
  • permissions – Contains the permissions to request. If None, the configuration value IPERNITY_PERMISSIONS is used. See there for data format.

  • next_url – URL to redirect to after returning from Ipernity.

Returns:

Redirect to the Ipernity authorization URL.

init_app(app: Flask)[source]

Initializes app for Flask-Ipernity.

This is called from the constructor if you pass an app to it. See Flask Extension Development for more information.

Note

If you are using the Flask-Login integration, make sure

Parameters:

appFlask application

logout()[source]

Logs out of Ipernity.

Deletes all session variables starting with IPERNITY_SESSION_PREFIX and removes the API token.

session_get(key: str, default: Any | None = None) Any[source]

Returns a session variable.

IPERNITY_SESSION_PREFIX is automatically prepended to key.

Parameters:
  • key – Name of the session variable.

  • default – Default value if variable is not present.

Returns:

The session variable.

session_pop(key: str, default: Any | None = None) Any[source]

Removes a session variable and returns it.

IPERNITY_SESSION_PREFIX is automatically prepended to key.

Parameters:
  • key – Name of the session variable.

  • default – Default value if variable is not present.

Returns:

The session variable.

session_set(key: str, value: Any)[source]

Sets a session variable.

IPERNITY_SESSION_PREFIX is automatically prepended to key.

Parameters:
  • key – Name of the session variable.

  • value – New value for variable.

set_token(frob: str | None = None)[source]

Sets the API token from frob.

Parameters:

frob – See Ipernity Authentication

property api: IpernityAPI

The current Ipernity API.

Depending on IPERNITY_CACHE_REQUESTS, the type is IpernityAPI or CachedIpernityAPI.

flask_ipernity.ipernity

LocalProxy of the current app’s Ipernity instance. Use this to access the Ipernity API

@flask_ipernity.ipernity_auth_required(permissions: Mapping[str, str] | None = None) Callable[source]

Decorator for a view that requires Ipernity authentication.

Parameters:

permissions – Contains the permissions required for the view. If None, the configuration value IPERNITY_PERMISSIONS is used. See there for data format.