Module ipernity.auth

Authentication and Authorization

The auth module defines the authentication handlers to be used with

digraph inheritancec0efd5666f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "AuthHandler" [URL="#ipernity.auth.AuthHandler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Generic authentication handler"]; "DesktopAuthHandler" [URL="#ipernity.auth.DesktopAuthHandler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Desktop authentication handler."]; "AuthHandler" -> "DesktopAuthHandler" [arrowsize=0.5,style="setlinewidth(0.5)"]; "WebAuthHandler" [URL="#ipernity.auth.WebAuthHandler",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Authentication for web applications"]; "AuthHandler" -> "WebAuthHandler" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

The authentication handlers provide access to the auth.* API methods and

class ipernity.auth.AuthHandler(api: IpernityAPI)[source]

Bases: ABC

Generic authentication handler

Parameters:

api – The API object to which the handler belongs.

property api: IpernityAPI

The corresponding IpernityAPI object

getToken(frob: str, store_token: bool = True, **kwargs: api_arg) dict[source]

Runs the [auth.getToken] API method.

By default, also stores the token and user info in the API object.

Parameters:
  • frob – String gotten via getFrob() or callback.

  • store_token – If True (the default), the token and user info will be stored in the API object (api).

  • kwargs – Passed to Ipernity as additional parameters.

Returns:

The result of the API call.

checkToken(auth_token: str, **kwargs: api_arg) dict[source]

Runs the [auth.checkToken] API method

abstract auth_url(perms: Mapping, **kwargs: str) str[source]

URL to pass to a web browser for authorization.

Parameters:

perms – Dictionary used to generate the perm_XXX parameters to the authorization URL. The keys can be doc, blog etc.

do_request(url: str, method_name: str, method_args: Mapping[str, api_arg]) requests.Response[source]

Signs and runs a request.

This is part of AuthHandler to make an OAuth handler possible, as OAuth uses a different format for signing and authentication info.

Parameters:
  • url – Request URL.

  • method_name – The method to be called (needed for signing).

  • method_args – Arguments of the method call.

class ipernity.auth.DesktopAuthHandler(api: IpernityAPI)[source]

Bases: AuthHandler

Desktop authentication handler.

Parameters:

api – The API object to which the handler belongs.

See also

getFrob() dict[source]

Get frob for authentication

See

auth_url(perms: Mapping, frob: str) str[source]

Authorization URL.

See Ipernity Permissions for a description.

Parameters:
  • perms – Dictionary used to generate the perm_XXX parameters to the authorization URL. The keys can be doc, blog etc.

  • frob – Data retrieved from getFrob()

class ipernity.auth.WebAuthHandler(api: IpernityAPI)[source]

Bases: AuthHandler

Authentication for web applications

Parameters:

api – The IpernityAPI object to which the handler belongs.

Added in version 0.1.3.

See also

auth_url(perms: Mapping[str, str]) str[source]

Authorization URL.

See Ipernity Permissions for a description.

Parameters:

perms – Dictionary used to generate the perm_XXX parameters to the authorization URL. The keys can be doc, blog etc.