Skip to main content

CLARIN SPF

Utility package to login to CLARIN's SPF and then collect the required session cookies for the login. These cookies can then be used to call the APIs of services that require authorization. Note that the pop-up login occurs in an isolated browser environment so no personal information or cookies are ever collected or used or even read.

The cookies are stored in locally in a file (by default in ~/.cache/clarin/cookies.json) and can be re-used for future requests. If they expire, the login window will automatically pop up again.

Installation

You can install the package from PyPI but you will also have to install the necessary browser utilities via playwright.

pip install clarin-spf
playwright install chromium --with-deps

For development:

git clone https://github.com/BramVanroy/clarin-spf
cd clarin-spf
pip install -e .[dev]
playwright install chromium --with-deps

Usage

Once you have logged in by initializing the ClarinRequester class, you can use the get, post, put, and delete methods to make requests to the CLARIN services. The cookies will be automatically added to the request headers. The request methods are identical to the requests package.

from clarin_spf import ClarinRequester

base_url = "https://portal.clarin.ivdnt.org/galahad"
clarin = ClarinRequester(trigger_url=base_url)
response = clarin.get(f"{base_url}/api/user").json()

print(f"Found user: {response['id']}")

See example usages in examples/.

To do

  • Investigate feasibility of using a headless browser
  • Investigate feasibility of running in notebooks
  • Investigate feasibility of running in CI/CD
  • Full MyPy compatible type hints
  • Add more tests where applicable
  • Improve handling of cookies: when they expire, the requests.get call will fail and just return HTML for the CLARIN discovery login. Incorporate common operations such as get, post, put, delete in the ClarinCredentials class, and when a json parse occurs, trigger a re-login request?

Metadata

Release files for clarin-spf 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clarin-spf 0.2.0
File Size Uploaded Provenance Actions
clarin_spf-0.2.0.tar.gz 19.7 kB Without provenance Details for clarin_spf-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for clarin-spf 0.2.0
File Interpreter ABI Platform Actions
clarin_spf-0.2.0-py3-none-any.whl Python 3 none any Details for clarin_spf-0.2.0-py3-none-any.whl

Total release size: 34.7 kB

Release files / clarin_spf-0.2.0.tar.gz

Download URL clarin_spf-0.2.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0ccb786873d7760b72b6818da348bb3d5b1bc23e48ef1899097615ed10295e29
BLAKE2b-256 checksum
How to use checksums
c2ded01a84ee6047b863c0f82bf7c880424422dc9f22ffb2b6023c859612961c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.7

Release files / clarin_spf-0.2.0-py3-none-any.whl

Download URL clarin_spf-0.2.0-py3-none-any.whl
Size 15.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2e780c85ce62b776d117cce89fd806c5fdd9f603027b1cf544c6ff8411c42bb
BLAKE2b-256 checksum
How to use checksums
d0bf91013c141e3aff94a171c4689df32f68651817811646ca3e626df5d58dde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.7

Security for clarin-spf 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page