OAuth问题总结

http://trinea.iteye.com/blog/1126507

1、OAuth retrieveRequestToken异常

用OAuth进行验证时,报下面的错误,网上排查良久无方。

Java代码   收藏代码
  1. oauth.signpost.exception.OAuthExpectationFailedException: Request token or token secret not set in server reply. The service provider you use is probably buggy.  

 后发现是应用的Consumer Key、Consumer secret

配错了,写成了

Access Token、Access Token Secret

汗。。

 

2、新浪发布微博出现如下异常

Xml代码   收藏代码
  1. java.lang.IllegalStateException: Neither user ID/password combination nor OAuth consumer key/secret combination supplied  

 出错代码

Java代码   收藏代码
  1. weibo4android.Status updateResult = weibo.updateStatus(StringUtils.utf8Encode(status));  

原因:

未提供comsumer key 

解决方法:

Java代码   收藏代码
  1. System.setProperty("weibo4j.oauth.consumerKey""CONSUMER_KEY");  
  2. System.setProperty("weibo4j.oauth.consumerSecret""CONSUMER_SECRET");  
 

 

3、发布sohu微博时,报如下异常

 

Xml代码   收藏代码
  1. java.io.IOException: Received authentication challenge is null  

 出错代码

Java代码   收藏代码
  1. HttpURLConnection request = (HttpURLConnection)url.openConnection();  
  2. request.setDoOutput(true);  
  3. request.setRequestMethod("POST");  
  4. HttpParameters para = new HttpParameters();  
  5. para.put("status", URLEncoder.encode("第一条""utf-8").replaceAll("\\+""%20"));  
  6. consumer.setAdditionalParameters(para);  
  7. consumer.sign(request);  
  8. OutputStream ot = request.getOutputStream();  
  9. ot.write(("status=" + URLEncoder.encode("中 文""utf-8")).replaceAll("\\+""%20").getBytes());  
  10. ot.flush();  
  11. ot.close();  
  12. System.out.println("Sending request...");  
  13. request.connect();  
  14. System.out.println("Response: " + request.getResponseCode() + " " + request.getResponseMessage());  

 上述代码中request.getResponseCode()时报异常

解决方法:

未解决,第二天重新执行错误消失。。

 

 

3、在android开发中我们需要充分利用线程及消息队列来处理需要长时间响应的操作,防止ui假死

 

4、腾讯微博认证异常

像https://open.t.qq.com/cgi-bin/request_token获取未授权的access token出现如下异常

Java代码   收藏代码
  1. java.lang.Exception: javax.net.ssl.SSLHandshakeException: org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate signature.  

 原因应该是以上请求的ssl证书已经不可用,将https改为http即可,如http://open.t.qq.com/cgi-bin/request_token

 

5、Conversion to Dalvik format failed with error 1

网上有各种原因,有project clean解决的,有修改android sdk版本解决的

我这次碰到的原因是因为依赖的外部包冲突了,同时依赖了A、B两个jar包,而A包已经在B包中

解决方法:去掉对B包的依赖


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值