-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch_auth_header.ps1
38 lines (27 loc) · 1.26 KB
/
fetch_auth_header.ps1
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
param (
$DeviceId = $null
)
if ($null -eq $DeviceId) {
$DeviceId = New-Guid
}
$links = @{
"ssoRegisterDevice" = "https://profile.callofduty.com/cod/mapp/registerDevice"
}
Write-Host "Register DEVICE_ID '$deviceId'..."
$CodSession = [Microsoft.PowerShell.Commands.WebRequestSession]::new()
$CodSession.Cookies.Add([System.Net.Cookie]::new("XSRF-TOKEN", "68e8b62e-1d9d-4ce1-b93f-cbe5ff31a041", "/", "profile.callofduty.com"))
$CodSession.Cookies.Add([System.Net.Cookie]::new("country", "US", "/", "profile.callofduty.com"))
$CodSession.Cookies.Add([System.Net.Cookie]::new("ACT_SSO_LOCALE", "US", "/", "profile.callofduty.com"))
$CodSession.Cookies.Add([System.Net.Cookie]::new("new_SiteId", "cod", "/", "profile.callofduty.com"))
$dataDevice = [PSCustomObject]@{
"deviceId" = $deviceId
} | ConvertTo-Json
$registerDeviceResponse = ((Invoke-WebRequest -Uri ($links.ssoRegisterDevice) -WebSession $CodSession -ContentType "application/json" -Method Post -Body $dataDevice).Content | ConvertFrom-Json)
if ("success" -ne ($registerDeviceResponse.status)) {
Write-Error "Can't register device: $(registerDeviceResponse.status)" -Category CloseError
return $null
}
return @{
authHeader = $registerDeviceResponse.data.authHeader
deviceId = $DeviceId
}