OAuth

Topics: Developer Forum
Sep 23, 2011 at 7:40 PM

Hi Sam,

I noticed that you recently added a first draft of an OAuth implementation.

My first question woudl be - what state do you feel your initial implementation is in, and when do you think it will be usable or stable?

 

I am trying to use the head rev with some sample code I found here: http://flickrnet.codeplex.com/wikipage?title=Examples&ProjectName=flickrnet

I did have to work out a couple of issues with getting the current code to run with this (still using the old auth code).

But when I try using

OAuthToken = flickr.OAuthGetRequestToken("oob");

I get an error response: oauth_problem=timestamp_refused

unfortunatley, flickr doesn't seem to give a reason.

I did notice that you probably need to truncate the timestamp to an int value, but the code variation below still returns the error response:

        public static string DateToUnixTimestamp(DateTime date)
        {
            TimeSpan ts = date - unixStartDate;
            int seconds = (int)ts.TotalSeconds;
            return seconds.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
        }
Any idea why this might be failing? (and yes, my pc clock should be pretty accurate on the time.)
Thanks
Coordinator
Sep 23, 2011 at 8:06 PM

I would say more than likely broken :D

Authentication should work (I think) but I think upload is broken in the current
version. I've possibly broken the old auth flow though, so very unstable at
the moment :(

My wife gave birth yesterday to our first little baby girl, so not likely to get fixed in the next week or so at the least.

I've never seen the timestamp_refused error during any of my testing. Might it be a timezone thing? If Flickr thinks the timestamp is in the future perhaps?

Sam

Sep 23, 2011 at 9:44 PM

Oh awsome! Congratulations! :-)

No problem, I expected as much. I'm just getting started - I'm still trasitioning from C++ to C#/.Net, and I haven't attempted http/web from this particular viewpoint. ;)

The timezone thing is a good place to look since I'm on central time. from what I can tell, everything else looks right.

I'll keep poking around with this, and if I happen to fix anything before I see an update, I'll be happy to share what I learn.

Enjoy your time with your new little girl The first years are the best, then they become teenagers, and it's payback time! :-0

Thanks, Cary

Sep 26, 2011 at 11:00 PM

You were exactly right. Use either DateTime.UtcNow, or convert it in the timestamp function with .ToUniversalTime(). It probably worked for you because your summer time (BST) is the same as GMT.

I got curious and had to find out why it worked - I used to hear Newcastle mentioned quite a bit when I worked for Midway. :)

Coordinator
Oct 20, 2011 at 4:24 PM

Hi

Just a quick email to say I released the new version of the FlickrNet library today which now fully supports OAuth.
Thanks for your work on this issue.

Sam

Oct 20, 2011 at 8:11 PM

Sam,

Thanks so much!  One thing I have not figured out - how do I get the verifier code?  AFAIK, The only way seems to be to use a webbrowser object, and in the navigated event parse the page or use regex. That seems rather risky. :P 

Ugh, OAuth has become the bane of my existance!

Thanks again, I'll be looking for a way to support your efforts.

Cary

Coordinator
Oct 20, 2011 at 8:29 PM

I've used a made up callback URL, and then in the navigating event look for that URL, and the parse the verifier code from the url.

Oct 20, 2011 at 11:41 PM

works great!

Feb 2, 2012 at 5:41 AM

Hi Sam,

I was wondering if the time_stamp refused was resolved for WP7 as well. I have been trying to request to get the request token, but get the same error message as mentioned above. Here is what I do to request a RequestToken.

 

Flickr flickr = new Flickr(my_key, my_secret);

flickr.OAuthGetRequestTokenAsync("http://dummy/oauth/", (_requestToken) { } );

 

The _requestToken has an error that says time_stamp refused. Can you let me know what might be wrong with my code?

Thanks,

Coordinator
Feb 2, 2012 at 7:51 AM

Yes, the fix was in the WP7 version as well, so you shouldn't be seeing an issue really.

Can I ask what timezone you are in?

Sam

Feb 2, 2012 at 3:21 PM

I am not sure if this will affect or not, but I am using a simulator for getting a request token. The timezone of simulator automatically gets assigned the same as my laptop.

The timezone I have used is PST. I also tried the UTC 00:00. But without success. Do I have to set the time zone somewhere from inside my app for FlickrNet?

Coordinator
Feb 2, 2012 at 3:23 PM

No, it should work whatever timezone you are using, its just the code gets the UTC time, so it shouldn't matter what timezone you are in really.

Could you use Fiddler to sniff the HTTP call to Flickr and then use a web site like this: http://www.epochconverter.com/ to convert the timestamp back to a normal time - and confirm that the time is the UTC time please.

Sam

Feb 2, 2012 at 7:10 PM

It seems to be an issue with my laptop. I tried to get the request token on another laptop and it worked perfectly. I will try again on my laptop and will post the results.

Feb 3, 2012 at 3:45 AM
Edited Feb 3, 2012 at 4:09 AM

Hi Sam,

Got it working on my laptop.. :) :) silly me.. The date was off by one.

Coordinator
Feb 3, 2012 at 7:52 AM

Yeah, that would do it :)