Skip to content

oldas.session

Provides a class for getting and managing a login session.

Session

Session(client, auth_code=None, timeout=60)

Class for handling a TheOldReader login session.

Parameters:

Name Type Description Default

client

str

The name of the client that is logging in.

required

auth_code

str | None

Optional authorization code to resume a session.

None

timeout

int

The timeout in seconds to use when making calls.

60
Note

The client should be a unique name you give your client application that is using this library.

auth_code property

auth_code

The auth code, if we are logged in, else None.

logged_in property

logged_in

Are we logged in?

add_tag async

add_tag(item, tag)

Add a tag to an item.

Parameters:

Name Type Description Default

item

str | list[str]

The item(s) to perform the edit on.

required

tag

str | State

The tag to add.

required

Returns:

Type Description
bool

The boolean result of the call.

get async

get(url, **params)

Make a GET call to the API.

Parameters:

Name Type Description Default

url

str

The URL to call.

required

params

Any

Any extra parameters that need to be passed.

{}

Returns:

Type Description
RawData

A dictionary that is the JSON data.

Raises:

Type Description
OldASError

If there was an error connecting or logging in.

login async

login(user, password)

Log into TheOldReader.

Parameters:

Name Type Description Default

user

str

The user name to log in with.

required

password

str

The password to log in with.

required

Returns:

Type Description
Self

Self.

Raises:

Type Description
OldASError

If there was an error connecting or logging in.

logout

logout()

Log out of the TheOldReader.

post async

post(url, **data)

Make a POST call to the API.

Parameters:

Name Type Description Default

url

str

The URL to call.

required

data

Any

The data to pass.

{}

Returns:

Type Description
bool

The boolean response from the API.

Raises:

Type Description
OldASError

If there was an error connecting or logging in.

remove_tag async

remove_tag(item, tag)

Remove a tag from an item.

Parameters:

Name Type Description Default

item

str | list[str]

The item(s) to perform the edit on.

required

tag

str | State

The tag to remove.

required

Returns:

Type Description
bool

The boolean result of the call.