forked from membrane/api-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.ps1
More file actions
19 lines (15 loc) · 660 Bytes
/
client.ps1
File metadata and controls
19 lines (15 loc) · 660 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$clientId = "abc"
$clientSecret = "def"
$tokenEndpoint = "http://localhost:8000/oauth2/token"
$target = "http://localhost:2000"
function getToken{
$postParams = @{grant_type="client_credentials";client_id=$clientId;client_secret=$clientSecret}
return Invoke-WebRequest -Uri $tokenEndpoint -Method POST -Body $postParams | ConvertFrom-Json
}
function sendRequestToTarget($tokenResult){
$headers = @{"Authorization"=$tokenResult.token_type + " " + $tokenResult.access_token}
return Invoke-WebRequest -Uri $target -Headers $headers
}
$tokenEndpointResult = getToken
$result = sendRequestToTarget $tokenEndpointResult
$result.StatusDescription