ValLib


NameValLib JSON
Version 1.4.0 PyPI version JSON
download
home_page
Summary
upload_time2024-01-11 20:29:20
maintainer
docs_urlNone
authorPWall
requires_python>=3.8
licenseGPL-3.0
keywords valorant api auth
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ValLib

[![PyPI - Version](https://img.shields.io/pypi/v/ValLib?label=ValLib)](https://pypi.org/project/ValLib/)
![GitHub deployments](https://img.shields.io/github/deployments/ValUtils/ValLib/deploy?label=deploy)
![GitHub](https://img.shields.io/github/license/ValUtils/ValLib)

A Python authentication module for the RiotGames API, and basic endpoint provider for Valorant.

## Features

- Full auth flow
- Request helpers
- Basic endpoints for Valorant
- Captcha "bypass" without using external services
- Ability to use external Captcha solvers

## Installation

The preferred method of installation is through `pip` but if you know better use the package manager that you want.

```sh
pip install ValLib
```

## Reference

### Basic structure

ValLib contains this basic building blocks:

- `User` a dataclass containing username and password
- `Auth` a dataclass containing ever auth param
- `AuthException` a exception class for **only** when the auth goes wrong because of Riot

And the following methods:

- `authenticate` to auth with username+password
- `cookie_token` to auth with cookies instead of username+password
- `make_headers` to convert `Auth` into headers for making requests

### Usage

#### Without API helper

```python
import ValLib
import requests

user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
headers = ValLib.make_headers(auth)
data = requests.get("https://auth.riotgames.com/userinfo", headers=headers)
print(data.json())
```

#### With API helper

```python
import ValLib

user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
data = ValLib.get("https://auth.riotgames.com/userinfo", auth)
print(data.json())
```

### Regions and Shards

Getting the region and the shard is often one of the most complicated of managing the API.
So for that we have the `get_region` and `get_shard` methods inside `ValLib.api` and the `ExtraAuth` dataclass inside `ValLib.structs`.

```python
import ValLib
from ValLib.api import get_region, get_shard
from ValLib.structs import ExtraAuth

user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
region = get_region(auth)
shard = get_shard(region)
extra = ExtraAuth(user.username, region, auth)
```

With this new instance of `ExtraAuth` we can use the custom API methods that require it of `ValLib.api`.

### Custom methods

Inside `ValLib.api` there are this customs methods:

- `get_preference` to fetch the in-game settings for Valorant
- `set_preference` to set the in-game settings for Valorant
- `get_load_out` to get the loadout (cosmetics + incognito) for Valorant
- `set_load_out` to set the loadout (cosmetics + incognito) for Valorant
- `get_session` to grab information about the current Valorant session

### Custom Captcha provider

If you need to make automatic auth or just need another way of dealing with captcha you can make your own `CaptchaSolver` class. Here is an example how to do so:

```python
import ValLib
import requests
from ValLib.captcha import CaptchaSolver, set_solver

class DumbCaptcha(CaptchaSolver):
    def token(self, rqdata, site_key):
        r = requests.get(
            "https://myapi.com",
            json={"rqdata": rqdata, "siteKey": site_key}
        )
        return r.text()

set_solver(DumbCaptcha())
user = ValLib.User("MyUser", "MyPass")
auth = ValLib.authenticate(user) # Will use api for captcha solving
```

**DISCLAIMER**: most captcha solving APIs exploit people to solve captchas so I'd recommend against using them but it's at your own risk.

### Custom MFA Code

When login into a MFA guarded account, the library will use a standard `input` for getting the MFA code, but you can use your own, here is an example:

```python
import ValLib
from ValLib.mfa import MfaInput, set_mfa

class MyMfa(MfaInput):
    def mfa(self) -> str:
        return magical_gui_input()

set_mfa(MyMfa())
user = ValLib.User("MyUser", "MyPass")
auth = ValLib.authenticate(user) # Will use your func for MFA input
```

## Roadmap

- [ ] Async
- [ ] More endpoints
- [ ] Better documentation
- [ ] Better exports

## Running Tests

Tests need to be run in a development environment with GUI, a navigator, `pytest` and filling this environment variables.

```sh
USERNAME="TestUser"
PASSWORD="TestPassword"
```

And then running `pytest`.

## Acknowledgements

- Thanks to [Valorant-API](https://valorant-api.com/) and their mantainers
- Thanks to [Hawolt](https://github.com/hawolt) for discovering the Captcha solver
- Thanks to [Techdoodle](https://github.com/techchrism) for his API docs
- Thanks to the Valorant App Developers discord

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ValLib",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "valorant,api,auth",
    "author": "PWall",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/db/c4/723b08b3aed8686e1d619eb631dd15ac39276fdc218bf4ed9bdf53a67278/ValLib-1.4.0.tar.gz",
    "platform": null,
    "description": "# ValLib\n\n[![PyPI - Version](https://img.shields.io/pypi/v/ValLib?label=ValLib)](https://pypi.org/project/ValLib/)\n![GitHub deployments](https://img.shields.io/github/deployments/ValUtils/ValLib/deploy?label=deploy)\n![GitHub](https://img.shields.io/github/license/ValUtils/ValLib)\n\nA Python authentication module for the RiotGames API, and basic endpoint provider for Valorant.\n\n## Features\n\n- Full auth flow\n- Request helpers\n- Basic endpoints for Valorant\n- Captcha \"bypass\" without using external services\n- Ability to use external Captcha solvers\n\n## Installation\n\nThe preferred method of installation is through `pip` but if you know better use the package manager that you want.\n\n```sh\npip install ValLib\n```\n\n## Reference\n\n### Basic structure\n\nValLib contains this basic building blocks:\n\n- `User` a dataclass containing username and password\n- `Auth` a dataclass containing ever auth param\n- `AuthException` a exception class for **only** when the auth goes wrong because of Riot\n\nAnd the following methods:\n\n- `authenticate` to auth with username+password\n- `cookie_token` to auth with cookies instead of username+password\n- `make_headers` to convert `Auth` into headers for making requests\n\n### Usage\n\n#### Without API helper\n\n```python\nimport ValLib\nimport requests\n\nuser = ValLib.User(\"Test\", \"TestPassword\")\nauth = ValLib.authenticate(user)\nheaders = ValLib.make_headers(auth)\ndata = requests.get(\"https://auth.riotgames.com/userinfo\", headers=headers)\nprint(data.json())\n```\n\n#### With API helper\n\n```python\nimport ValLib\n\nuser = ValLib.User(\"Test\", \"TestPassword\")\nauth = ValLib.authenticate(user)\ndata = ValLib.get(\"https://auth.riotgames.com/userinfo\", auth)\nprint(data.json())\n```\n\n### Regions and Shards\n\nGetting the region and the shard is often one of the most complicated of managing the API.\nSo for that we have the `get_region` and `get_shard` methods inside `ValLib.api` and the `ExtraAuth` dataclass inside `ValLib.structs`.\n\n```python\nimport ValLib\nfrom ValLib.api import get_region, get_shard\nfrom ValLib.structs import ExtraAuth\n\nuser = ValLib.User(\"Test\", \"TestPassword\")\nauth = ValLib.authenticate(user)\nregion = get_region(auth)\nshard = get_shard(region)\nextra = ExtraAuth(user.username, region, auth)\n```\n\nWith this new instance of `ExtraAuth` we can use the custom API methods that require it of `ValLib.api`.\n\n### Custom methods\n\nInside `ValLib.api` there are this customs methods:\n\n- `get_preference` to fetch the in-game settings for Valorant\n- `set_preference` to set the in-game settings for Valorant\n- `get_load_out` to get the loadout (cosmetics + incognito) for Valorant\n- `set_load_out` to set the loadout (cosmetics + incognito) for Valorant\n- `get_session` to grab information about the current Valorant session\n\n### Custom Captcha provider\n\nIf you need to make automatic auth or just need another way of dealing with captcha you can make your own `CaptchaSolver` class. Here is an example how to do so:\n\n```python\nimport ValLib\nimport requests\nfrom ValLib.captcha import CaptchaSolver, set_solver\n\nclass DumbCaptcha(CaptchaSolver):\n    def token(self, rqdata, site_key):\n        r = requests.get(\n            \"https://myapi.com\",\n            json={\"rqdata\": rqdata, \"siteKey\": site_key}\n        )\n        return r.text()\n\nset_solver(DumbCaptcha())\nuser = ValLib.User(\"MyUser\", \"MyPass\")\nauth = ValLib.authenticate(user) # Will use api for captcha solving\n```\n\n**DISCLAIMER**: most captcha solving APIs exploit people to solve captchas so I'd recommend against using them but it's at your own risk.\n\n### Custom MFA Code\n\nWhen login into a MFA guarded account, the library will use a standard `input` for getting the MFA code, but you can use your own, here is an example:\n\n```python\nimport ValLib\nfrom ValLib.mfa import MfaInput, set_mfa\n\nclass MyMfa(MfaInput):\n    def mfa(self) -> str:\n        return magical_gui_input()\n\nset_mfa(MyMfa())\nuser = ValLib.User(\"MyUser\", \"MyPass\")\nauth = ValLib.authenticate(user) # Will use your func for MFA input\n```\n\n## Roadmap\n\n- [ ] Async\n- [ ] More endpoints\n- [ ] Better documentation\n- [ ] Better exports\n\n## Running Tests\n\nTests need to be run in a development environment with GUI, a navigator, `pytest` and filling this environment variables.\n\n```sh\nUSERNAME=\"TestUser\"\nPASSWORD=\"TestPassword\"\n```\n\nAnd then running `pytest`.\n\n## Acknowledgements\n\n- Thanks to [Valorant-API](https://valorant-api.com/) and their mantainers\n- Thanks to [Hawolt](https://github.com/hawolt) for discovering the Captcha solver\n- Thanks to [Techdoodle](https://github.com/techchrism) for his API docs\n- Thanks to the Valorant App Developers discord\n",
    "bugtrack_url": null,
    "license": "GPL-3.0",
    "summary": "",
    "version": "1.4.0",
    "project_urls": {
        "Homepage": "https://github.com/ValUtils/ValLib"
    },
    "split_keywords": [
        "valorant",
        "api",
        "auth"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cf633b1cadbd27e847be4df2e1d2ca75e9490cbb5eb316c3319215e1076b56a2",
                "md5": "0e9e1d81d802255f0882636a430c6435",
                "sha256": "1eec9753c5ea092a3307706453f200646512f63f215d9d2c967453bee16f2fbc"
            },
            "downloads": -1,
            "filename": "ValLib-1.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0e9e1d81d802255f0882636a430c6435",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 33656,
            "upload_time": "2024-01-11T20:29:18",
            "upload_time_iso_8601": "2024-01-11T20:29:18.584661Z",
            "url": "https://files.pythonhosted.org/packages/cf/63/3b1cadbd27e847be4df2e1d2ca75e9490cbb5eb316c3319215e1076b56a2/ValLib-1.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dbc4723b08b3aed8686e1d619eb631dd15ac39276fdc218bf4ed9bdf53a67278",
                "md5": "31ef9396e0959f2eac254b241b2dd6e3",
                "sha256": "be948ccc040dd015076677e4e6dc3fc88dd954563b385807ed9aa3c584ff1a9b"
            },
            "downloads": -1,
            "filename": "ValLib-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "31ef9396e0959f2eac254b241b2dd6e3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 28108,
            "upload_time": "2024-01-11T20:29:20",
            "upload_time_iso_8601": "2024-01-11T20:29:20.105398Z",
            "url": "https://files.pythonhosted.org/packages/db/c4/723b08b3aed8686e1d619eb631dd15ac39276fdc218bf4ed9bdf53a67278/ValLib-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-11 20:29:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ValUtils",
    "github_project": "ValLib",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "vallib"
}
        
Elapsed time: 0.19603s