我正在尝试对Dynamics 365进行令牌访问(协议oauth2)。
这是构建和执行http post请求的代码:
URI uri = new URIBuilder()
.setScheme("https")
.setHost("login.microsoftonline.com")
.setPath("/"+PropertyUtils.getInstance().getProperty("AD_TENANT_ID")+"/oauth2/token")
.setParameter("grant_type", "client_credentials")
.setParameter("client_id", PropertyUtils.getInstance().getProperty("CLIENT_ID"))
.setParameter("resource", PropertyUtils.getInstance().getProperty("RESOURCE"))
.setParameter("client_secret", PropertyUtils.getInstance().getProperty("CLIENT_SECRET"))
.build();
HttpPost post = new HttpPost(uri);
HttpResponse response = client.execute(post);
响应json是:
{"error":"invalid_request","error_description":"AADSTS900144: The request body must contain the following parameter: 'grant_type'.\r ...
为什么响应告诉我Grant_type在请求中作为参数丢失?