我正在将我的应用程序与Hubspot CRM集成。我需要使用OAuth2.0获取Access令牌。我启动了授权并尝试使用HTTPClient获取访问令牌。但我无法得到回应。我在下面添加了我的代码。我正在做的错误是什么,我在用于启动授权时使用相同的重定向uri。
代码
String grant_type = "authorization_code";
HttpPost post = new HttpPost("https://api.hubapi.com/oauth/v1/token");
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("code", code));
nvps.add(new BasicNameValuePair("client_id", client_id));
nvps.add(new BasicNameValuePair("client_secret", client_secret));
nvps.add(new BasicNameValuePair("redirect_uri", redirect_uri));
nvps.add(new BasicNameValuePair("grant_type", grant_type));
post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
DefaultHttpClient httpClients = new DefaultHttpClient();
HttpResponse response = httpClients.execute(post);
响应错误
HTTP/1.1 400 Bad Request
{"status":"BAD_AUTH_CODE","message":"missing or unknown auth code","correlationId":"e33b84e6-6a60-47c4-8f66-d2826fcada44","requestId":"e74fa273f7e927a21dd5a0676c0f0e61"}