0

token rejected

I'm trying to do basic send receive of instant message using yahoo api in c# web app. i followed the documentation and obtainted temp oauth_token, oauth_token_secret and session handle and the long oauth_token. but when i try to create a session, i get unauthorized error. Captured HTTP packet says Yahoo XML error is "Please provide valid credentials. OAuth oauth_problem="token_rejected", realm="yahooapis.com""

any help greatly appreciated!!

by
5 Replies
  • this is the code im using:
    CODE
                    string uri = "http://developer.messenger.yahooapis.com/v1/session?";
    uri += "&oauth_token=" + oauth_token;
    uri += "&oauth_session_handle=" + oauth_session_handle;
    uri += "&xoauth_yahoo_guid=" + yahoo_guid;
    uri += "&oauth_consumer_key=" + WebConfigurationManager.AppSettings["oauth_consumer_key"];
    uri += "&oauth_signature_method=PLAINTEXT";
    uri += "&oauth_version=1.0";
    uri += "&oauth_timestamp=" + Convert.ToInt32(time_stamp);
    uri += "&oauth_nonce=" + GetNonce(time_stamp);
    uri += "&oauth_signature=" + WebConfigurationManager.AppSettings["oauth_consumer_secret"] + "%26" + oauth_token_secret;
    uri += "&notifyServerToken=1";

    Response.Write(String.Format("<br/><br/>Sending &not request to {0}<br/>", uri));

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    request.Method = "POST";
    request.ContentType = JSONContentType;

    string session_data = "{\"presenceState\" : 1, \"presenceMessage\" : \"" + "Online Is Me" + "\"}";
    byte[] array = Encoding.UTF8.GetBytes(session_data);
    request.ContentLength = session_data.Length;
    Stream stream = request.GetRequestStream();
    stream.Write(array, 0, array.Length);
    stream.Close();

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    0
  • Could you try this

    Thx
    ~jimmi
    0
  • QUOTE (Sandy World @ Sep 12 2010, 04:41 PM) <{POST_SNAPBACK}>
    this is the code im using:
    CODE
                    string uri = "http://developer.messenger.yahooapis.com/v1/session?";
    uri += "&oauth_token=" + oauth_token;
    uri += "&oauth_session_handle=" + oauth_session_handle;
    uri += "&xoauth_yahoo_guid=" + yahoo_guid;
    uri += "&oauth_consumer_key=" + WebConfigurationManager.AppSettings["oauth_consumer_key"];
    uri += "&oauth_signature_method=PLAINTEXT";
    uri += "&oauth_version=1.0";
    uri += "&oauth_timestamp=" + Convert.ToInt32(time_stamp);
    uri += "&oauth_nonce=" + GetNonce(time_stamp);
    uri += "&oauth_signature=" + WebConfigurationManager.AppSettings["oauth_consumer_secret"] + "%26" + oauth_token_secret;
    uri += "&amp;notifyServerToken=1";

    Response.Write(String.Format("<br/><br/>Sending &not request to {0}<br/>", uri));

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    request.Method = "POST";
    request.ContentType = JSONContentType;

    string session_data = "{\"presenceState\" : 1, \"presenceMessage\" : \"" + "Online Is Me" + "\"}";
    byte[] array = Encoding.UTF8.GetBytes(session_data);
    request.ContentLength = session_data.Length;
    Stream stream = request.GetRequestStream();
    stream.Write(array, 0, array.Length);
    stream.Close();

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    Thank you for your code!
    But how do you define the oauth_token,oauth_session_handle,yahoo_guid and so on?
    Can you send me the whole Code project? I just want do realize the function of login and send messenger!
    Thank you again!
    0
  • QUOTE (Sandy World @ Sep 12 2010, 04:41 PM) <{POST_SNAPBACK}>
    this is the code im using:
    CODE
                    string uri = "http://developer.messenger.yahooapis.com/v1/session?";
    uri += "&oauth_token=" + oauth_token;
    uri += "&oauth_session_handle=" + oauth_session_handle;
    uri += "&xoauth_yahoo_guid=" + yahoo_guid;
    uri += "&oauth_consumer_key=" + WebConfigurationManager.AppSettings["oauth_consumer_key"];
    uri += "&oauth_signature_method=PLAINTEXT";
    uri += "&oauth_version=1.0";
    uri += "&oauth_timestamp=" + Convert.ToInt32(time_stamp);
    uri += "&oauth_nonce=" + GetNonce(time_stamp);
    uri += "&oauth_signature=" + WebConfigurationManager.AppSettings["oauth_consumer_secret"] + "%26" + oauth_token_secret;
    uri += "&amp;notifyServerToken=1";

    Response.Write(String.Format("<br/><br/>Sending &not request to {0}<br/>", uri));

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
    request.Method = "POST";
    request.ContentType = JSONContentType;

    string session_data = "{\"presenceState\" : 1, \"presenceMessage\" : \"" + "Online Is Me" + "\"}";
    byte[] array = Encoding.UTF8.GetBytes(session_data);
    request.ContentLength = session_data.Length;
    Stream stream = request.GetRequestStream();
    stream.Write(array, 0, array.Length);
    stream.Close();

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    Thank you for your code!
    But how do you define the oauth_token,oauth_session_handle,yahoo_guid and so on?
    Can you send me the whole Code project? I just want do realize the function of login and send messenger!
    Thank you again! my emai: jackk_rr@yahoo.com.
    0
  • that worked perfect mr. Jimmi! got the session id in response. Thanks!
    0

Recent Posts

in Messenger IM SDK