我對Twitter的這一請求,利用javax.ws.rs微博使用的oauth2 javax.ws.rs
WebTarget target = new WebTargetBuilder(client, OAUTH_API_ENDPOINT).build();
Builder request = target
.request(MediaType.APPLICATION_JSON)
.header("Authorization", "Basic " + encodedCredentials)
.header("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
Response postResponse = request
.post(Entity.entity("grant_type=client_credentials", MediaType.TEXT_PLAIN));
System.out.println(postResponse.readEntity(String.class));
encodedCredentials是我的祕密消費品和消費的關鍵在基地64
請求我的編碼「M試圖做的是:
POST /oauth2/token HTTP/1.1
Host: api.twitter.com
User-Agent: My Twitter App v1.0.23
Authorization: Basic eHZ6MWV2RlM0d0VFUFRHRUZQSEJvZzpMOHFxOVBaeVJn
NmllS0dFS2hab2xHQzB2SldMdzhpRUo4OERSZHlPZw==Content-Type: application/x-www- form-urlencoded;charset=UTF-8
Content-Length: 29
Accept-Encoding: gzip
grant_type=client_credentials
我不斷收到403禁止:{ 「錯誤」:[{ 「代碼」:170, 「消息」: 「缺少必需的參數:grant_type」, 「標籤」:」 forbidden_missing_parameter「}]}
看起來帖子正文沒有設置正確,任何人都知道如何設置它?
這就是它,謝謝.. – Jones