Skip to main content

A Python package to interact with the CLARIN SPF API to retrieve the 'logged in' cookies necessary to potentially interact with APIs of services that require the authentication.

Project description

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.

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

For development:

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

playwright install

Usage

from clarin_spf import clarin_login
import requests

# The interface URL is the URL of a service that will trigger the SPF login screen
# It does not have to be related to the final API you want to call
interface_url = "https://url.to.an.interface.com"
# The API URL is the URL of the API you want to call
api_url = "https://url.to.your.com/api/endpoint"

cookies = clarin_login(interface_url)
response = requests.get(api_url, cookies=cookies).json()

See example usages in examples/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clarin_spf-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

clarin_spf-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file clarin_spf-0.1.0.tar.gz.

File metadata

  • Download URL: clarin_spf-0.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for clarin_spf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 36237e3798abed894be67938fa8e6465e37bcbf37f1a101b24e99992653bd978
MD5 4f1a6b2f5a45d68f16dc83abbb77bd68
BLAKE2b-256 a06455c500da78d2384138cf0bf6a03e35984820a12cb2d3ece2c26b30df2387

See more details on using hashes here.

File details

Details for the file clarin_spf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clarin_spf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for clarin_spf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1e0cc364fcfa3e9cc5cac83d4a7a1e7fe70e4d6cc20e133a9932631864c1ddd
MD5 8616667a65aaa2dece6c5d1d01c1b72f
BLAKE2b-256 7945d6c671721fa7c8d5f4ea41bb3b09618abf599957245cc537880d143e0ab0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page