What the title says is what this snippet is.
Last active
March 30, 2023 20:32
-
-
Save JeffJacobson/43e3146cca0bc83fd306260d727e9348 to your computer and use it in GitHub Desktop.
ArcGIS Online / Portal Powershell scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Token { | |
[string] $token | |
[System.DateTimeOffset] $expires | |
Token($response) { | |
$this.token = $response.token; | |
$this.expires = [System.DateTimeOffset]::FromUnixTimeMilliseconds($response.expires) | |
} | |
} | |
$rootUri = "https://www.arcgis.com/sharing/rest" | |
$params = @{ | |
username = "me"; | |
password = "mypassword"; | |
expiration = '60' | |
referer = 'https://wsdot.maps.arcgis.com' | |
f = 'json' | |
} | |
$tokenUri = "$rootUri/generateToken" | |
$response = Invoke-RestMethod -Uri $tokenUri -Method Post -Body $params | |
$token = New-Object Token $response | |
return $token |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment