-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.rb
More file actions
60 lines (49 loc) · 1.36 KB
/
Copy pathexample.rb
File metadata and controls
60 lines (49 loc) · 1.36 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
60
# Authon Ruby SDK - Full Usage Example
# Run: ruby example.rb
require_relative 'authon'
# ============ SETUP ============
auth = Authon.new('your-app-id', 'your-api-key')
# ============ CONNECT ============
unless auth.init
puts '[-] Failed to connect to Authon API'
exit 1
end
puts "[+] Connected: #{auth.app_name} v#{auth.app_version}"
# ============ AUTHENTICATE ============
puts "\n[1] Login (Username + Password)"
puts '[2] License Key'
print "\n> "
choice = gets.chomp
if choice == '1'
print 'Username: '
username = gets.chomp
print 'Password: '
password = gets.chomp
result = auth.login(username, password)
else
print 'License Key: '
key = gets.chomp
result = auth.license(key)
end
unless result['success']
puts "\n[-] #{result['message']}"
exit 1
end
puts "\n[+] Authenticated!"
puts " Level: #{auth.level}"
puts " Subscription: #{auth.subscription || 'None'}"
puts " Expires: #{auth.expires_at || 'Lifetime'}"
# ============ USE FEATURES ============
msg = auth.get_var('welcome_message')
puts "\n[*] #{msg}" if msg
files = auth.list_files
if files.any?
puts "\n[*] Available files (#{files.length}):"
files.each_with_index do |f, i|
puts " [#{i + 1}] #{f['name']} (#{(f['size'] || 0) / 1024} KB)"
end
end
auth.log('Ruby SDK example executed')
# ============ CLEANUP ============
puts "\n[+] Done. Logging out..."
auth.logout