{"id":21389379,"url":"https://github.com/bramvanroy/clarin-spf","last_synced_at":"2025-03-16T12:46:27.669Z","repository":{"id":262652631,"uuid":"887933640","full_name":"BramVanroy/clarin-spf","owner":"BramVanroy","description":"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.","archived":false,"fork":false,"pushed_at":"2024-11-16T10:28:12.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-07T21:07:30.896Z","etag":null,"topics":["api","clarin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BramVanroy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-13T14:32:07.000Z","updated_at":"2024-11-16T10:28:16.000Z","dependencies_parsed_at":"2024-11-13T15:50:31.745Z","dependency_job_id":null,"html_url":"https://github.com/BramVanroy/clarin-spf","commit_stats":null,"previous_names":["bramvanroy/clarin-spf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BramVanroy%2Fclarin-spf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BramVanroy%2Fclarin-spf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BramVanroy%2Fclarin-spf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BramVanroy%2Fclarin-spf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BramVanroy","download_url":"https://codeload.github.com/BramVanroy/clarin-spf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243871650,"owners_count":20361378,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","clarin"],"created_at":"2024-11-22T12:26:11.215Z","updated_at":"2025-03-16T12:46:27.648Z","avatar_url":"https://github.com/BramVanroy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLARIN SPF\n\nUtility 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.\n\nThe 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.\n\n\n## Installation\n\nYou can install the package from PyPI but you will also have to install the necessary browser utilities via playwright.\n\n```shell\npip install clarin-spf\nplaywright install chromium --with-deps\n```\n\nFor development:\n\n```shell\ngit clone https://github.com/BramVanroy/clarin-spf\ncd clarin-spf\npip install -e .[dev]\nplaywright install chromium --with-deps\n```\n\n## Usage\n\nOnce 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. Depending on how long the cookies are valid **you will not have to login again for quite some time**, improving usability greatly. The cookies will be automatically added to the request headers for all future requests. When at some point that does not work anymore, you will be redirected to login again. The request methods are identical to the `requests` package.\n\n```python\nfrom clarin_spf import ClarinRequester\n\nbase_url = \"https://portal.clarin.ivdnt.org/galahad\"\nclarin = ClarinRequester(trigger_url=base_url)\nresponse = clarin.get(f\"{base_url}/api/user\").json()\n\nprint(f\"Found user: {response['id']}\")\n```\n\nSee example usages in [examples/](examples/).\n\n\n## To do\n\n- [ ] Investigate feasibility of using a headless browser\n- [ ] Investigate feasibility of running in notebooks\n- [ ] Investigate feasibility of running in CI/CD\n- [ ] Full MyPy compatible type hints\n- [ ] Add more tests where applicable\n- [x] Improve handling of cookies: when they expire, the `requests.get` call will fail and just return HTML for\nthe CLARIN discovery login. Incorporate common operations such as `get`, `post`, `put`, `delete` in the\n`ClarinCredentials` class, and when a json parse occurs, trigger a re-login request?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramvanroy%2Fclarin-spf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramvanroy%2Fclarin-spf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramvanroy%2Fclarin-spf/lists"}