J'essaie simplement d'obtenir un jeton d'accès de l'ID du client, du secret client et de l'ID du locataire. Suite à la commande powershell fonctionne avec succèsMicrosoft Azure get l'API du jeton d'accès ne fonctionne pas avec cURL/Ruby mais fonctionne avec powershell
Invoke-RestMethod -Uri https://login.microsoftonline.com/TENANT/oauth2/token?api-version=1.0 -Method Post -Body @{"grant_type" = "client_credentials"; "resource" = "https://management.core.windows.net/"; "client_id" = "CLIENTID"; "client_secret" = "SECRET" }
Mais cette boucle ne fonctionne pas
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "grant_type=client_credentials&resource=https://management.core.windows.net/&client_id=CLIENTID&client_secret=SECRET" "https://login.microsoftonline.com/TENANT/oauth2/token?api-version=1.0"
Ni ce script Ruby
require 'json'
require 'typhoeus'
url = 'https://login.microsoftonline.com/TENANT/oauth2/token?api-version=1.0'
params = "grant_type=client_credentials&resource=https://management.core.windows.net/&client_id=CLIENTID&client_secret=SECRET"
HEADERS = {
"Content-Type" => "application/x-www-form-urlencoded"
}
resp = Typhoeus::Request.post(url, body: params, headers: HEADERS)
Je suis le lien suivant this. Des indices pourquoi ni curl/ruby ne fonctionne? Merci à l'avance
Quel est le message d'erreur? – ehoffmann