fail to retrieve request token for yahoo integration in android?
Asked Answered
L

2

2

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.

Leeuwenhoek answered 5/8, 2011 at 18:0 Comment(12)
Hi i get a similar error , have you solved this issue???Faludi
@KC203 No I am still trying for the same... stuck with 404 error....Leeuwenhoek
Thanks for the reply , i have seen several forum , everyone seems to have this problem , i doubt if this is possible also now .Anyways do let me know if you successful integrate yahooFaludi
@Leeuwenhoek - From what I know, you cannot give a custom callback url scheme to Yahoo - which means, you have to give a callback URL starting with http or https, and then intercept the call in a WebView. That said however, I stopped getting 404, but still get 401, and I'm not sure why !Housley
Hi Panache, i wanna also in my apps, able to login application using any off the yahoo, google plus account. but i am not found any way please sugest me or post code to helpfull for me for integration.Fulcher
Do you have a sample code for this integration?Richburg
@Leeuwenhoek +1 for your question and i have the same problem can you help meMargret
@Margret sure... I will post some sample code by tomorrow. Will this work for u..?Leeuwenhoek
@Leeuwenhoek Okay sure and thanks for your reply. I think there is problem in call back url. What i have to put in call back url. I have just placed as "Application name" +"//:" + "oauth". but it is not working. Tell me what i did wrongMargret
If its related to call back url here is what I have used, consider App Name is "TestYahoo" then in Android Mainfest for that Activity, <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:host="TestYahoo" android:scheme="oauth" /> which i made browsable, and the call back url used is, "oauth://TestYahoo".Leeuwenhoek
@Leeuwenhoek Ya i did like this <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="oauth" android:host="Integration Sample" /> </intent-filter> String CALLBACK_URL = "oauth" + "://" +"Integration Sample"; . But it shows "oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider failed: api.login.yahoo.com ". Why so?Margret
@Leeuwenhoek Can you please provide me a working code for this? I have been dealing with problem for several hours now. Thanks.Richburg
H
3
  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.

Housley answered 21/8, 2011 at 12:55 Comment(5)
thanks for the reply. I have some questions, 1. why we have to register as Web-Based app, we do have option of Client based app? 2. I tried with web based, but not getting what to mention is Application URL and Application Domain? Plz will you post some steps for the same... thanks sir.Leeuwenhoek
I've edited my answer to include what you need to give as App url and App domain. You can give Desktop-based, but in that case, after the authentication, the user has to copy a code, and paste it in your application after the verification is done. If you want seamless integration without any copy pasting, you need to follow a web-based authentication model. Please let me know if you have any questions.Housley
can you post some working code? This will help me get things working.Leeuwenhoek
sir, stop getting 404, stuck with Authorization failed (server replied with a 401). This can happen if the consumer key was not correct or the signatures did not match. My consumer key is right one, then why its giving this error.Leeuwenhoek
Sir, solved... thanks. The problem is with callback url. Now I am trying to get user information from yahoo.Leeuwenhoek
C
1

I had followed the above mentioned 3#poits and able to do the call back to the application. The whole problem started with YAHOO OAUTH Process. Now Yahoo doesnt take the Custom Call back urls, It has to be a valid http url. n There are couple of issues i have it which i am solving on my own,like Having a CUSTOMi Dialog box which can be used to call the Web-view YAHOO Auth URL similar to FB Dialog.

Thanks for the

Culbert answered 10/11, 2011 at 12:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.