This project has moved. For the latest updates, please go here.
1
Vote

GetAuthInstance returning 403 in v3.14

description

Hi Sam,

Been informed that an old(ish) client site is returning a 403 forbidden when calling Flickr.PeopleFindbyEmail();

I've upgraded via Nuget to v3.14 but still getting the 403. Here's the code:
public class FlickrManager
    {
        public const string ApiKey = "MYKEY";
        public const string SharedSecret = "MYSECRET";

        public static Flickr GetInstance()
        {
            return new Flickr(ApiKey, SharedSecret);
        }

        public static Flickr GetAuthInstance()
        {
            return new Flickr(ApiKey, SharedSecret)
            {
                OAuthAccessToken = OAuthToken,
                OAuthAccessTokenSecret = OAuthTokenSecret
            };
        }

        public static string OAuthToken
        {
            get
            {
                if (!HttpContext.Current.Request.Cookies.AllKeys.Contains("OAuthToken"))
                {
                    return null;
                }
                return HttpContext.Current.Request.Cookies["OAuthToken"].Value;
            }
            set
            {
                HttpContext.Current.Response.AppendCookie(new HttpCookie("OAuthToken", value));
            }
        }

        public static string OAuthTokenSecret
        {
            get
            {
                if (!HttpContext.Current.Request.Cookies.AllKeys.Contains("OAuthTokenSecret"))
                {
                    return null;
                }
                return HttpContext.Current.Request.Cookies["OAuthTokenSecret"].Value;
            }
            set
            {
                HttpContext.Current.Response.AppendCookie(new HttpCookie("OAuthTokenSecret", value));
            }
        }
    }
and the caller:
Flickr f = FlickrManager.GetAuthInstance();
        protected void Page_Load(object sender, EventArgs e)
        {
            string userID = f.PeopleFindByEmail("tehidy.slade@yahoo.com").UserId; //bombs here

            var photSets = f.PhotosetsGetList(userID);

            var photos = from x in photSets
                         select new
                         {
                             SetDescription = x.Description,
                             SetTitle = x.Title.ToLower().Replace(" ", "-"),
                             Small320Url = x.PhotosetSmallUrl,
                             SetId = x.PhotosetId
                         };

            rptPhotos.DataSource = photos;
            rptPhotos.DataBind();
        }
The OAuthToken and OAuthTokenSecret are both null. Any ideas? Do I need new a new key and secret?

Thanks.
Brett

comments

samjudson wrote Aug 5, 2014 at 3:33 PM

I can't see anything obviously wrong with the code.

What type of exception is thrown, a WebException or a FlickrApiException? Can you use something like Fiddler to look at the HTTPS traffic and see what the error is?

There isn't a proxy that requires authentication involved is there?

Sam

samjudson wrote Aug 5, 2014 at 3:33 PM

Another thought, try creating the instance of Flickr inside the Page_Load method.

Kryptos wrote Aug 9, 2014 at 5:49 PM

I've just opened an old app.. because users said they were seeing errors and I'm seeing this too.. None of the examples work either... unless I'm missing something.

samjudson wrote Aug 9, 2014 at 6:20 PM

Well the 403 error is usually because you are not calling the HTTPS endpoint, but if you have successfully upgraded to 3.14 then that shouldn't be the case. Can you try using Fiddler to look at the traffic, and see if it really is using HTTPS or not?

brettderry wrote Aug 10, 2014 at 6:39 PM

Sam,

It's definitely still calling the HTTP endpoint: Here's confirmation from Fiddler:

POST http://api.flickr.com/services/rest/ HTTP/1.1
Authorization: OAuth oauth_nonce="179f6a2f0fa84961b8cb08cefd56cc9f",oauth_timestamp="1407695713.48334",oauth_version="1.0",oauth_signature_method="HMAC-SHA1",oauth_consumer_key="5686e5c24247820b6951d2f461fb9a51"
Content-Type: application/x-www-form-urlencoded
Host: api.flickr.com
Content-Length: 69
Expect: 100-continue
Connection: Keep-Alive

method=flickr.people.findByEmail&find_email=tehidy.slade%40yahoo.com&

brettderry wrote Aug 10, 2014 at 6:46 PM

Sam,

Not sure if something's wrong with 3.14 (obtained via Nuget) but downloaded to 3.13 and it works as expected.

Brett

samjudson wrote Aug 11, 2014 at 10:53 AM

This is really weird. I've downloaded the nuget package myself, and it is definitely the latest version with HTTPS.

Shyoshya wrote Aug 12, 2014 at 6:47 AM

Hi,

I second the opinion that 3.13 solves the issue but not 3.14

regards,
Shirong