0

401 when asking for request token

401 when asking for request token

Hi there

I still get a 401 when asking for a request token. the URL I use is the following:

https://api.login.yahoo.com/oauth/v2/get_re...stingdomain.com


I use the following parameters:
oauth_consumer_key = dj0yJmk9Z25hV21ITkRkY0RHJmQ9WVdrOVJqTlFRVWw0TjJjbWNHbzlNVEUwTXpJMk1EQTJNZy0tJnM9
Y29uc3VtZXJzZWNyZXQmeD0yNg--, oauth_nonce = 8891580198842859494, oauth_signature_method = HMAC-SHA1, oauth_timestamp = 1273566655, oauth_version = 1.0, xoauth_lang_pref = en-us

Tried different libs for javascript and java because I supposed there was a problem with signing the request. But now I think it has something to do with the Yahoo application configuration. It is marked as "OAuth Application" but the domain is not verified. In the documentation is stated that the application should work nevertheless. But maybe: Do my requests have to be made from the domain which I configured for the application ? Could that be the reason for still getting 401 ?

Thanks for your help !

by
2 Replies
  • I guess I had some problem with signing the request. Now I use signpost and it works fine!
    This is my solution. It does not use a callback yet, instead you have to copy and paste the pin you receiver after login to yahoo

    Map<String, Object> model = new HashMap<String, Object>();

    // create a consumer object and configure it with the access
    // token and token secret obtained from the service provider
    OAuthConsumer consumer = new DefaultOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);

    OAuthProvider provider = new DefaultOAuthProvider("https://api.login.yahoo.com/oauth/v2/get_request_token", "https://api.login.yahoo.com/oauth/v2/get_token",
    "https://api.login.yahoo.com/oauth/v2/request_auth");

    // /STEP 1 ///
    String authUrl = provider.retrieveRequestToken(consumer, "http://amoser.gmx.com:8080/yahooexampleapp/newsinfo.html"/* OAuth.OUT_OF_BAND */);

    // /STEP 2, user input ///
    String pinCode = "";
    // Breakpoint here: Call authURL via browser, you will receive a pincode. Set Pincode here !

    // STEP 3, user has to be authenticated //
    provider.retrieveAccessToken(consumer, pinCode);

    // make 3-legged user info request
    URL url = new URL(
    "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20social.profile%20where%20guid%3Dme&format=json&diagnostics=true&callback=cbfunc");
    HttpURLConnection request = (HttpURLConnection) url.openConnection();
    // sign the request
    consumer.sign(request);
    // send the request
    request.connect();

    // response status should be 200 OK
    int statusCode = request.getResponseCode();
    System.out.println("response code: " + statusCode);
    System.out.println("response: " + request.getResponseMessage());

    BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream()));
    String inputLine;

    StringBuilder builder = new StringBuilder();
    while ((inputLine = in.readLine()) != null)
    builder.append(inputLine);
    in.close();




    QUOTE (Alisa @ May 11 2010, 04:00 AM) <{POST_SNAPBACK}>
    401 when asking for request token

    Hi there

    I still get a 401 when asking for a request token. the URL I use is the following:

    https://api.login.yahoo.com/oauth/v2/get_re...stingdomain.com


    I use the following parameters:
    oauth_consumer_key = dj0yJmk9Z25hV21ITkRkY0RHJmQ9WVdrOVJqTlFRVWw0TjJjbWNHbzlNVEUwTXpJMk1EQTJNZy0tJnM9
    Y29uc3VtZXJzZWNyZXQmeD0yNg--, oauth_nonce = 8891580198842859494, oauth_signature_method = HMAC-SHA1, oauth_timestamp = 1273566655, oauth_version = 1.0, xoauth_lang_pref = en-us

    Tried different libs for javascript and java because I supposed there was a problem with signing the request. But now I think it has something to do with the Yahoo application configuration. It is marked as "OAuth Application" but the domain is not verified. In the documentation is stated that the application should work nevertheless. But maybe: Do my requests have to be made from the domain which I configured for the application ? Could that be the reason for still getting 401 ?

    Thanks for your help !
    0
  • Made your post invisible (not accessible to the public) as there was a request that appeared to be from you stating that there was private data. I wasn't sure which data you meant (I see a key, but no secret), so I am trying to err on the side of caution. I do also have the ability to edit your posts if you'd like to keep your solution posted and just remove the parts that you don't want published. Let me know if you'd like me to edit the posts or if you still want them blown away.
    0

Recent Posts

in OAuth General Discussion YDN SDKs