CURL to Powershell et TOKEN
Bonjour,
Je cherche à récupérer un token d'un site qui s'actualise tous les " jours qui me permettra ensuite d'utiliser l'API de ce dernier
Avec Postman j'ai obtenu un token avec cette commande
Code:
1 2 3 4 5 6 7
|
curl -X POST \
http://monsite.com/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Postman-Token: TOKEN' \
-H 'cache-control: no-cache' \
-d 'grant_type=password&username=User&password=Password&undefined=' |
J'aimerai convertir cette commande en powershell mais j'obtient toujours une erreur
[CODEInvoke-RestMethod : {"error":"unsupported_grant_type"}[/CODE]
j'ai ce code :
Code:
1 2 3 4 5 6 7
| $Username = "User"
$PassWord = "Password"
$uri = "http://monsite.com/token"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $Username,$PassWord)))
Invoke-WebRequest -uri $uri -Method Post -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} |
merci de votre aide