-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ps1
More file actions
48 lines (38 loc) · 1.51 KB
/
Copy pathexample.ps1
File metadata and controls
48 lines (38 loc) · 1.51 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
# Authon PowerShell SDK - Example
# Run: .\example.ps1
. "$PSScriptRoot\Authon.ps1"
# ============ SETUP ============
$auth = New-Authon -AppId "your-app-id" -ApiKey "your-api-key"
# ============ CONNECT ============
if (-not (Initialize-Authon $auth)) {
Write-Host "[-] Failed to connect" -ForegroundColor Red
exit 1
}
Write-Host "[+] Connected: $($auth.AppName) v$($auth.AppVersion)" -ForegroundColor Green
# ============ AUTHENTICATE ============
Write-Host "`n[1] Login (Username + Password)"
Write-Host "[2] License Key"
$choice = Read-Host "`n>"
if ($choice -eq "1") {
$username = Read-Host "Username"
$password = Read-Host "Password"
$result = Login-Authon $auth -Username $username -Password $password
} else {
$key = Read-Host "License Key"
$result = License-Authon $auth -Key $key
}
if (-not $result.success) {
Write-Host "`n[-] $($result.message)" -ForegroundColor Red
exit 1
}
Write-Host "`n[+] Authenticated!" -ForegroundColor Green
Write-Host " Level: $($auth.Level)"
Write-Host " Subscription: $(if ($auth.Subscription) { $auth.Subscription } else { 'None' })"
Write-Host " Expires: $(if ($auth.ExpiresAt) { $auth.ExpiresAt } else { 'Lifetime' })"
# ============ FEATURES ============
$msg = Get-AuthonVar $auth -Key "welcome_message"
if ($msg) { Write-Host "`n[*] $msg" -ForegroundColor Cyan }
Send-AuthonLog $auth -Message "PowerShell SDK example executed"
# ============ CLEANUP ============
Write-Host "`n[+] Done. Logging out..." -ForegroundColor Green
Logout-Authon $auth