-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.lua
More file actions
59 lines (48 loc) · 1.43 KB
/
Copy pathexample.lua
File metadata and controls
59 lines (48 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
--[[
Authon Lua SDK - Full Usage Example
Run: lua example.lua
]]
local Authon = require("authon")
-- ============ SETUP ============
local auth = Authon.new("your-app-id", "your-api-key")
-- ============ CONNECT ============
if not auth:init() then
print("[-] Failed to connect to Authon API")
os.exit(1)
end
print("[+] Connected: " .. (auth.appName or "?") .. " v" .. (auth.appVersion or "?"))
-- ============ AUTHENTICATE ============
print("\n[1] Login (Username + Password)")
print("[2] License Key")
io.write("\n> ")
local choice = io.read()
local result
if choice == "1" then
io.write("Username: ")
local username = io.read()
io.write("Password: ")
local password = io.read()
result = auth:login(username, password)
else
io.write("License Key: ")
local key = io.read()
result = auth:license(key)
end
if not result.success then
print("\n[-] " .. (result.message or "Unknown error"))
os.exit(1)
end
print("\n[+] Authenticated!")
print(" Level: " .. tostring(auth.level))
print(" Subscription: " .. (auth.subscription or "None"))
print(" Expires: " .. (auth.expiresAt or "Lifetime"))
-- ============ USE FEATURES ============
local msg = auth:getVar("welcome_message")
if msg then print("\n[*] " .. msg) end
auth:log("Lua SDK example executed")
if auth:check() then
print("\n[+] Session is valid")
end
-- ============ CLEANUP ============
print("\n[+] Done. Logging out...")
auth:logout()