Rubika: A Python library for interacting with the Rubika Login APi.
Project description
Rubika Login Example
This is a simple example showing how to use the rulog Python library to:
- Send a verification code to a phone number.
- Login to Rubika using the received code.
- Register the device.
Installation
Make sure you have installed the rulog library:
pip install rulog
Example Code
from rulog import Client
# Create a Client instance
Client = Client()
# ===== Send code =====
def send_code(phone):
try:
# Try sending via Android platform with send_type=True
response = Client.sendCode("android", phone, send_type=True)
return response['data']['phone_code_hash']
except Exception as e:
print("❌ Android send failed. Trying Web...")
try:
response = Client.sendCode("web", phone)
return response['data']['phone_code_hash']
except Exception as e:
print("❌ Sending code failed:", e)
return None
# ===== Login =====
def login(phone, hash_code, code):
try:
response = Client.signIn("android", phone, hash_code, code)
print("✅ Login successful.")
return response
except Exception as e:
print("❌ Login failed:", e)
return None
# ===== Register device =====
def register(auth, key):
try:
result = Client.register(platform="android", auths=auth, keys=key)
if result:
print("✅ Registration successful.")
return True
else:
print("❌ Registration failed.")
return False
except Exception as e:
print("❌ Registration error:", e)
return False
# ===== Main execution =====
if __name__ == "__main__":
phone = input("📱 Enter your phone number (e.g., 9891...): ").strip()
hash_code = send_code(phone)
if not hash_code:
print("🚫 Code sending failed. Exiting.")
exit()
code = input("🔢 Enter the received code: ").strip()
login_response = login(phone, hash_code, code)
if login_response:
register(login_response['Auth'], login_response['Key'])
How it works
- Send code: Sends a verification code to the phone using Android first, then Web if failed.
- Login: Signs in using the phone number, hash code, and received code.
- Register: Registers the device using the authentication keys received after login.
Notes
- Ensure your phone number format is correct.
- The script handles simple retries for sending codes.
- The library
rulogmust be installed.
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
rulog-1.0.1.tar.gz
(11.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
rulog-1.0.1-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file rulog-1.0.1.tar.gz.
File metadata
- Download URL: rulog-1.0.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c14ddf882f1e93b93411fb2191ad3a7da7c906c38c65d50dab8def1f2425f0b
|
|
| MD5 |
7913e0e9fdea37f38b3f6f56732ae6fc
|
|
| BLAKE2b-256 |
aabe2c39b7f30bca164183534d0055aaa8d1ebad2aa5d5f75dc7ca0a2074770b
|
File details
Details for the file rulog-1.0.1-py3-none-any.whl.
File metadata
- Download URL: rulog-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04d272d3b505487afcf55ec903b479f31f52a221e1c3957fa9aa3bf76092edb8
|
|
| MD5 |
78f25950cc59dd71bebd837c7745bab1
|
|
| BLAKE2b-256 |
e95bdb293de4d695c8fa406daeb2ced47505de0cbb439c114357f6449e59a4ff
|