无法检索android系统中整合雅虎请求令牌? [英] fail to retrieve request token for yahoo integration in android?

查看:187
本文介绍了无法检索android系统中整合雅虎请求令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想雅虎在我的应用程序集成。我想,

 私有静态最后弦乐YAHOO_CALLBACK_URI =MyApp的:// OAuth的;
公共静态最后弦乐YAHOO_REQUEST_TOKEN_URL =htt​​p://api.login.yahoo.com/oauth/request_token\";//api.login.yahoo.com
公共静态最后弦乐YAHOO_ACCESS_TOKEN_URL =htt​​p://api.login.yahoo.com/oauth/access_token;
公共静态最后弦乐YAHOO_AUTHORIZE_URL =htt​​p://api.login.yahoo.com/authorize;
CommonsHttpOAuthConsumer消费=新CommonsHttpOAuthConsumer(YAHOO_CONSUMER_KEY,YAHOO_CONSUMER_SERECT_KEY);
    OAuthProvider提供商=新CommonsHttpOAuthProvider(YAHOO_REQUEST_TOKEN_URL,YAHOO_ACCESS_TOKEN_URL,YAHOO_AUTHORIZE_URL);
    provider.setOAuth10a(真);
    尝试{
        字符串authUrl = provider.retrieveRequestToken(消费者,YAHOO_CALLBACK_URI); //我可以传递NULL回调URL。
        的System.out.println(AuthURL =+ authUrl);
    }赶上(OAuthMessageSignerException E){
        e.printStackTrace();
    }赶上(OAuthNotAuthorizedException E){
        e.printStackTrace();
    }赶上(OAuthExpectationFailedException E){
        e.printStackTrace();
    }赶上(OAuthCommunicationException E){
        e.printStackTrace();
    }

获得

oauth.signpost.exception.OAuthCommunicationException:与服务提供商通信失败:服务提供商回应错误:404(未找到)

为什么我们无法检索请求令牌。


解决方案

  1. 确保您的应用程序雅虎注册为基于Web的。当您注册一个基于Web的应用程序,提供有效的应用程序URL和您所选择的应用程序域(都应该是相同的域),但尚未使用的其他任何人。我举个例子,有一个网站,我自己的网址。这也将被用作在消费者回调URL。

  2. 而不是调用MyApp的:// OAuth的,给予有效的HTTP回调URL(您用来注册应用程序的相同)。有了这么多,你的code以上应该工作。

  3. 打开一个新的网页视图,并调用authUrl。一旦程序被授权,通过重写onPageStarted的方法拦截调用您的应用程序URL。还有,做一个回调到您的应用程序通过推出一个新的意图指向MyApp的:// OAuth的。

请让我知道如果任何obove步骤迷惑你 - 我很乐意去帮助更多

I am trying to integrate yahoo in my app. I am trying,

private static final String YAHOO_CALLBACK_URI = "MyApp://oauth";
public static final String YAHOO_REQUEST_TOKEN_URL = "http://api.login.yahoo.com/oauth/request_token";//api.login.yahoo.com
public static final String YAHOO_ACCESS_TOKEN_URL = "http://api.login.yahoo.com/oauth/access_token";
public static final String YAHOO_AUTHORIZE_URL = "http://api.login.yahoo.com/authorize";


CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(YAHOO_CONSUMER_KEY, YAHOO_CONSUMER_SERECT_KEY);
    OAuthProvider provider = new CommonsHttpOAuthProvider(YAHOO_REQUEST_TOKEN_URL, YAHOO_ACCESS_TOKEN_URL, YAHOO_AUTHORIZE_URL);
    provider.setOAuth10a(true);
    try {
        String authUrl = provider.retrieveRequestToken(consumer, YAHOO_CALLBACK_URI);// Can I pass Null for callback url.
        System.out.println("AuthURL = " + authUrl);
    } catch (OAuthMessageSignerException e) {
        e.printStackTrace();
    } catch (OAuthNotAuthorizedException e) {
        e.printStackTrace();
    } catch (OAuthExpectationFailedException e) {
        e.printStackTrace();
    } catch (OAuthCommunicationException e) {
        e.printStackTrace();
    }

getting

oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: Service provider responded in error: 404 (Not Found)

Why we are unable to retrieve request token.

解决方案

  1. Make sure your app on Yahoo is registered as Web-Based. When you register as a Web-Based application, give a valid Application URL and App Domain of your choice (both should be the same domain), but has not been used by anyone else. I, for example, have the url of a website I own. This will also be used as the callback url in your consumer.
  2. Instead of calling "MyApp://oauth", give a valid http callback url (the same one you used to register the app). With that much, your code above should work.
  3. Open a new Webview and call the authUrl. Once your app is authorised, intercept the call to your application url by overriding the "onPageStarted" method. There, make a callback to your app by launching a new intent pointing to "MyApp://oauth".

Please let me know if any of the obove steps confuse you - I am more than happy to help.

这篇关于无法检索android系统中整合雅虎请求令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆