0

Getting 403 error while trying to access contact book

Hi everyone,

I am getting the 403 error when trying to access the contacts from the yahoo address book.

Here is my code where I am getting the error

if (Request.QueryString["token"] != null && Request.QueryString["token"].Length > 0)
{
if (auth.IsValidSignedUrl(Request.Url) == true)
{
auth.Token = Request.QueryString["token"];
auth.UpdateCredentials();
//Uri uri1 = new Uri("http://address.yahooapis.com/api/ws/v1/searchContacts");
string url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields= name,email";
url += "&appid=" + auth.ApplicationId;
url += "&wssid=" + auth.WssId;
Uri address = new Uri(url);

DataSet ds = auth.GetAuthenticatedServiceDataSet(address);

I don't know what I am doing wrong here or may be I am missing something. Please let me know. Your help is needed here.

Thanks
Sumit

by
33 Replies
  • QUOTE (tribedeveloper @ Mar 20 2009, 02:27 AM) <{POST_SNAPBACK}>
    I am getting the 403 error when trying to access the contacts from the yahoo address book.

    Here is my code where I am getting the error

    <snip>
    string url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields= name,email";
    url += "&appid=" + auth.ApplicationId;
    url += "&wssid=" + auth.WssId;

    Uri address = new Uri(url);

    DataSet ds = auth.GetAuthenticatedServiceDataSet(address);

    I don't know what I am doing wrong here or may be I am missing something. Please let me know. Your help is needed here.


    Hi Sumit,

    It looks like you're appending the application ID and WSS ID to the URL. You don't need to do this when calling GetAuthenticatedServiceDataSet() (or the other Auth methods) as the class will do this for you. Try removing the lines I highlighted in bold above.

    //Tomi B.
    0
  • Hi Tomy,

    Thank you very much for your help...Now it's working for me. I think I was also doing it the same way but didn't work for me. then I changed and posted the code
    0
  • QUOTE (tribedeveloper @ Mar 25 2009, 12:14 AM) <{POST_SNAPBACK}>
    Hi Tomy,

    Thank you very much for your help...Now it's working for me. I think I was also doing it the same way but didn't work for me. then I changed and posted the code


    :(Surprisingly when I call the auth.GetAuthenticatedServiceString(new System.Uri(address.ToString())) function it works for me and give me the output as a string. I am unable to figure out what's going wrong.
    0
  • QUOTE (tribedeveloper @ Mar 25 2009, 04:53 AM) <{POST_SNAPBACK}>
    :(//Tomi B.
    0
  • Dear all,

    I have the same problem, getting 403 error

    Here's my code :
    Request authentication :
    CODE
        protected void lbImportYahoo_Click(object sender, EventArgs e)
    {
    string yahooid = ConfigurationSettings.AppSettings["_app"];
    string yahoosecret = ConfigurationSettings.AppSettings["_secret"];
    Yahoo.YahooAuthentication auth = new Yahoo.YahooAuthentication(yahooid, yahoosecret);
    string loginAddress = auth.GetUserLogOnAddress().ToString();
    Response.Redirect(loginAddress);
    }


    After request authentication, now trying to retrieve the contacts
    CODE
        protected static string yahooid = ConfigurationSettings.AppSettings["_app"];
    protected static string yahoosecret = ConfigurationSettings.AppSettings["_secret"];

    private Yahoo.YahooAuthentication auth = new Yahoo.YahooAuthentication(yahooid, yahoosecret);

    protected void Page_Load(object sender, EventArgs e)
    {
    if (Request.QueryString["token"] != null && Request.QueryString["token"].Length > 0)
    {
    if (auth.IsValidSignedUrl(Request.Url) == true)
    {
    // Given token to Authentication class
    auth.Token = Request.QueryString["token"];

    // TODO: Save the token and its timeout date in a secure persistent store.

    // Attempt to retrieve user credentials
    auth.UpdateCredentials();

    if (auth.IsCredentialed == true)
    {
    string url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields=name,email";
    System.Data.DataSet dsServices;
    try
    {
    dsServices = auth.GetAuthenticatedServiceDataSet(new System.Uri(url));
    }
    catch (Exception ex)
    {
    lblAddress.Text = "token : " + auth.Token + " ID : " + auth.ApplicationId + " cookies : " + auth.Cookies + " wssid : " + auth.WssId;
    }
    }
    }
    }
    }


    This is the address that I want to retrieve from
    http://address.yahooapis.com/v1/searchCont...SSID=*censored*

    I'm able to login, but when it's processing the login, I got error in here : dsServices = auth.GetAuthenticatedServiceDataSet(new System.Uri(url));

    or, to be exact, when it tried to get the response :
    response = request.GetResponse() as System.Net.HttpWebResponse;

    Somehow, I still got forbidden error eventhough I got all set (including the token and the cookies

    Please advice
    0
  • OK, I figured it out. The problem is that the DOCTYPE in the returned data is pointing to an invalid URL. I'll put in a bug report on this.

    In the meantime, you can work around the issue by not using GetAuthenticatedDataSet(), but using GetAuthenticatedStream() and a custom XmlReader with options set to _not_ use the DTD. I wrote up a short blog post with details and a very short example:
    http://bliny.net/blog/post/Using-BBAuth-wi...dress-Book.aspx

    //Tomi B.
    0
  • Tomi B,
    Did you get any solution, or anyone else got any solution. As i have tried you blog example as well, but it is giving me same error.

    Please help.

    thanks
    0
  • QUOTE (zish @ Apr 29 2009, 08:19 AM) <{POST_SNAPBACK}>
    Tomi B,
    Did you get any solution, or anyone else got any solution. As i have tried you blog example as well, but it is giving me same error.

    Please help.

    thanks


    Which error are you getting currently, 404 or 403? They are different issues.

    //Tomi B.
    0
  • Hi Sumit,

    Since so many days I am facing problem in login through API. Alway i am getting message as "Invalid (src)/appid". Could you please help me in this. Why I am asking u this because u don't have any problem in login and trying to get contact details. That's why I am asking you.

    Regards,
    Bhavani

    QUOTE (tribedeveloper @ Mar 20 2009, 02:27 AM) <{POST_SNAPBACK}>
    Hi everyone,

    I am getting the 403 error when trying to access the contacts from the yahoo address book.

    Here is my code where I am getting the error

    if (Request.QueryString["token"] != null && Request.QueryString["token"].Length > 0)
    {
    if (auth.IsValidSignedUrl(Request.Url) == true)
    {
    auth.Token = Request.QueryString["token"];
    auth.UpdateCredentials();
    //Uri uri1 = new Uri("http://address.yahooapis.com/api/ws/v1/searchContacts");
    string url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields= name,email";
    url += "&appid=" + auth.ApplicationId;
    url += "&wssid=" + auth.WssId;
    Uri address = new Uri(url);

    DataSet ds = auth.GetAuthenticatedServiceDataSet(address);

    I don't know what I am doing wrong here or may be I am missing something. Please let me know. Your help is needed here.

    Thanks
    Sumit
    0
  • QUOTE (zish @ Apr 29 2009, 08:19 AM) <{POST_SNAPBACK}>
    Tomi B,
    Did you get any solution, or anyone else got any solution. As i have tried you blog example as well, but it is giving me same error.

    Please help.

    thanks
    k tal mis amiguis {os}
    SQL
    SELECT t.tid FROM a_table t WHERE t.val="This Value
    0
  • in our app, we are also getting intermittent 403 errors, but if we refresh the page that imports the contacts it usually is able to load up the contacts....if you keep refresh multiple times, most likely there is at least one 403 error...how can this be resolved?
    0
  • QUOTE (Khan @ Aug 4 2009, 06:23 AM) <{POST_SNAPBACK}>
    in our app, we are also getting intermittent 403 errors, but if we refresh the page that imports the contacts it usually is able to load up the contacts....if you keep refresh multiple times, most likely there is at least one 403 error...how can this be resolved?


    having same problem, any solutions?
    0
  • I've escalated this to the Address Book team.

    Robyn Tippins
    Community Manager, YDN
    0
  • I've done some digging and 403 is an auth error which typically means invalid credentials – wrong appid, wrong cookie, wrong token, etc. Is that a possibility? Can you go back and check to make sure these are correct and let me know?

    Robyn Tippins
    Community Manager, YDN
    0
  • I'm also getting the 403 error.

    I'm using the following code-

    Yahoo.Authentication auth = new Yahoo.Authentication("xxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxx");

    // Redirect the user to the use sign-in page
    if (Request["token"] == null)
    Response.Redirect(auth.GetUserLogOnAddress().ToString());
    else
    auth.Token = Request["token"];
    auth.UpdateCredentials();

    XmlDocument doc = auth.GetAuthenticatedServiceXmlDocument(new Uri("http://address.yahooapis.com/api/ws/v1/searchContacts?format=xml&fields=name,email"));
    string xmlll = doc.InnerXml;

    QUOTE (duzins @ Sep 3 2009, 09:26 AM) <{POST_SNAPBACK}>
    I've done some digging and 403 is an auth error which typically means invalid credentials – wrong appid, wrong cookie, wrong token, etc. Is that a possibility? Can you go back and check to make sure these are correct and let me know?

    Robyn Tippins
    Community Manager, YDN
    0
  • It seems either the C# library has bug or address book web service is not working as we are trying the use the library provided by Yahoo.
    Can someone give more information on this error "403 Forbidden error"?
    0
  • Raj,

    Have you double-checked your credentials? That error means the system thinks your creds are bad. If they aren't, I need to go back and do more digging, but I need confirmation from you first that they are correct.

    Thank you,
    Robyn Tippins
    Community Manager, YDN
    0
  • Yes, I got the token also after authentication. So, I'm assuming that all my credentials are right.
    I got the cookie also like Y=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    Raj,

    Have you double-checked your credentials? That error means the system thinks your creds are bad. If they aren't, I need to go back and do more digging, but I need confirmation from you first that they are correct.

    Thank you,
    Robyn Tippins
    Community Manager, YDN
    [/quote]
    0
  • Robyn

    Can you help to figure out the problem?


    Yes, I got the token also after authentication. So, I'm assuming that all my credentials are right.
    I got the cookie also like Y=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    Raj,

    Have you double-checked your credentials? That error means the system thinks your creds are bad. If they aren't, I need to go back and do more digging, but I need confirmation from you first that they are correct.

    Thank you,
    Robyn Tippins
    Community Manager, YDN
    [/quote]
    0
  • Raj,

    It would be helpful to see your code. If you don't want to share it here, feel free to ping me via email: rtippins at yahoo-inc.com

    Robyn
    0
  • I have downloaded the Yahoo .net library and the client is as follows -
    Yahoo.Authentication auth = new Yahoo.Authentication(XXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXx");

    // Redirect the user to the use sign-in page
    if (Request["token"] == null)
    Response.Redirect(auth.GetUserLogOnAddress().ToString());
    else
    auth.Token = Request["token"];
    auth.UpdateCredentials();
    if (auth.IsCredentialed)
    {
    url = System.Web.HttpUtility.UrlPathEncode(
    "http://address.yahooapis.com/v1/searchContacts"
    + "?format=xml"
    + "&fields=name,phone,email"
    + "&appid=" + auth.ApplicationId
    + "&WSSID=" + auth.WssId);

    Uri uurl = auth.SignUrl(new Uri(url));
    System.Net.HttpWebRequest req =
    System.Net.WebRequest.Create(uurl)
    as System.Net.HttpWebRequest;

    //req.Headers = new System.Net.WebHeaderCollection();
    //req.Headers.Add("Y", auth.Cookies.Trim().Remove(0, 2));

    //System.Net.Cookie cky = new System.Net.Cookie("Y",
    //auth.Cookies.Trim().Remove(0, 2));
    //cky.Expires = auth.ValidUntil;
    //cky.Domain = url;

    //req.CookieContainer = new System.Net.CookieContainer();
    //req.CookieContainer.Add(cky);
    req.Headers.Add("Cookie", auth.Cookies.Trim().Remove(0, 2));

    //ERRORS ON THIS LINE!!
    using (System.Net.HttpWebResponse res = req.GetResponse()
    as System.Net.HttpWebResponse)
    {
    // Get the response stream
    System.IO.StreamReader reader = new System.IO.StreamReader(
    res.GetResponseStream());

    // Console application output
    Console.WriteLine(reader.ReadToEnd());
    }
    }
    0
  • Robyn

    I replied to you by email as well as I have uploaded the code also but I haven't received any feed back.
    I appreciate if you can give me some feedback.

    Raj,

    It would be helpful to see your code. If you don't want to share it here, feel free to ping me via email: rtippins at yahoo-inc.com

    Robyn
    [/quote]
    0
  • Hi Everyone,

    My issue got resolved after I went to this link :DSumit
    0
  • QUOTE (tribedeveloper @ Oct 28 2009, 11:20 PM) <{POST_SNAPBACK}>
    Hi Everyone,

    My issue got resolved after I went to this link :DPlease help me. : truongtinhnguyen@gmail.com
    0
  • Everyone Having same problem(403)..
    I thought there is no problem with credentials [we tried GetAuthenticatedServiceStream and GetAuthenticatedServiceDataSet methods] we used the below URI for this

    url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields=name,email";

    Any Help in this issue? Any one got solution?

    QUOTE (Raj @ Sep 14 2009, 03:48 PM) <{POST_SNAPBACK}>
    Robyn

    Can you help to figure out the problem?


    Yes, I got the token also after authentication. So, I'm assuming that all my credentials are right.
    I got the cookie also like Y=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


    Raj,

    Have you double-checked your credentials? That error means the system thinks your creds are bad. If they aren't, I need to go back and do more digging, but I need confirmation from you first that they are correct.

    Thank you,
    Robyn Tippins
    Community Manager, YDN
    0
  • is this form dead?
    0
  • Sumit,

    That API has been deprecated. It's still up and running, but we are not actively supporting it. You should look at the <a href="http://developer.yahoo.com/social/rest_api_guide/contact_api.html"Contacts API</a>. Thanks,

    Cheers!
    Robyn Tippins
    @duzins on Twitter
    Community Manager, YDN

    0
  • QUOTE (duzins @ Jan 30 2010, 11:38 AM) <{POST_SNAPBACK}>
    Sumit,

    That API has been deprecated. It's still up and running, but we are not actively supporting it. You should look at the <a href="http://developer.yahoo.com/social/rest_api_guide/contact_api.html"Contacts API</a>. Thanks,

    Cheers!
    Robyn Tippins
    @duzins on Twitter
    Community Manager, YDN




    I still can't get address book from yahoo with using yahoo API. Can everyone help me or provide sample code in C#?
    0
  • QUOTE (kenneth @ Feb 8 2010, 02:18 AM) <{POST_SNAPBACK}>
    I still can't get address book from yahoo with using yahoo API. Can everyone help me or provide sample code in C#?

    I m having the same issue ..i tried both
    string url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields=name,email";
    Stream dataStream = auth.GetAuthenticatedServiceStream(new Uri(url));
    dsServices = auth.GetAuthenticatedServiceDataSet(new System.Uri(url));

    but still getiing 403 error ...help
    0
  • QUOTE (duzins @ Sep 3 2009, 09:26 AM) <{POST_SNAPBACK}>
    I've done some digging and 403 is an auth error which typically means invalid credentials – wrong appid, wrong cookie, wrong token, etc. Is that a possibility? Can you go back and check to make sure these are correct and let me know?

    Robyn Tippins
    Community Manager, YDN

    hi Robyn
    I m having the same issue .. i m getting cookies, wssid and all
    i tried both
    string url = "http://address.yahooapis.com/v1/searchContacts?format=xml&fields=name,email";
    Stream dataStream = auth.GetAuthenticatedServiceStream(new Uri(url));
    dsServices = auth.GetAuthenticatedServiceDataSet(new System.Uri(url));

    but still getiing 403 error ...pls help
    0
  • That API has been deprecated and we are no longer supporting it. Please look at the Contacts API if you would like to get the same data and technical support. http://developer.yahoo.com/social/contacts/

    Thanks,

    Robyn Tippins
    @duzins on Twitter
    Community Manager, YDN

    ***Follow YDN on Twitter and Facebook***
    0
  • QUOTE (duzins @ Feb 11 2010, 11:19 PM) <{POST_SNAPBACK}>
    That API has been deprecated and we are no longer supporting it. Please look at the Contacts API if you would like to get the same data and technical support. http://developer.yahoo.com/social/contacts/

    Thanks,

    Robyn Tippins
    @duzins on Twitter
    Community Manager, YDN

    ***Follow YDN on Twitter and Facebook***



    Could you please write sample about how to get the contacts with the new API IN C# please , i have tried much but not working,

    could you do this plase?
    0
  • Could you please write sample about how to get the contacts with the new API IN C# please , i have tried much but not working,

    could you do this plase?
    0

Recent Posts

in .NET Development