A Python authentication module for the RiotGames API, and basic endpoint provider for Valorant.
- Full auth flow
- Request helpers
- Basic endpoints for Valorant
- Captcha "bypass" without using external services
- Ability to use external Captcha solvers
The preferred method of installation is through pip
but if you know better use the package manager that you want.
pip install ValLib
ValLib contains this basic building blocks:
User
a dataclass containing username and passwordAuth
a dataclass containing ever auth paramAuthException
a exception class for only when the auth goes wrong because of Riot
And the following methods:
authenticate
to auth with username+passwordcookie_token
to auth with cookies instead of username+passwordmake_headers
to convertAuth
into headers for making requests
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())
import ValLib
user = ValLib.User("Test", "TestPassword")
auth = ValLib.authenticate(user)
data = ValLib.get("https://auth.riotgames.com/userinfo", auth)
print(data.json())
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
.
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
.
Inside ValLib.api
there are this customs methods:
get_preference
to fetch the in-game settings for Valorantset_preference
to set the in-game settings for Valorantget_load_out
to get the loadout (cosmetics + incognito) for Valorantset_load_out
to set the loadout (cosmetics + incognito) for Valorantget_session
to grab information about the current Valorant session
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:
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.
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:
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
- Async
- More endpoints
- Better documentation
- Better exports
Tests need to be run in a development environment with GUI, a navigator, pytest
and filling this environment variables.
USERNAME="TestUser"
PASSWORD="TestPassword"
And then running pytest
.
- Thanks to Valorant-API and their mantainers
- Thanks to Hawolt for discovering the Captcha solver
- Thanks to Techdoodle for his API docs
- Thanks to the Valorant App Developers discord