Core functionality¶
This module defines the Flask extension.
- class flask_ipernity.Ipernity(app: Flask | None = None)[source]¶
Bases:
objectClass 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_urland 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 valueIPERNITY_PERMISSIONSis 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
appfor 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:
app – Flask application
- logout()[source]¶
Logs out of Ipernity.
Deletes all session variables starting with
IPERNITY_SESSION_PREFIXand removes the API token.
- session_get(key: str, default: Any | None = None) Any[source]¶
Returns a session variable.
IPERNITY_SESSION_PREFIXis automatically prepended tokey.- 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_PREFIXis automatically prepended tokey.- 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_PREFIXis automatically prepended tokey.- 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 isIpernityAPIorCachedIpernityAPI.
- flask_ipernity.ipernity¶
LocalProxyof the current app’sIpernityinstance. 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 valueIPERNITY_PERMISSIONSis used. See there for data format.