Pass callback URL to flickr during token request

Topics: Developer Forum
Aug 20, 2011 at 7:44 PM

I have a scenario where we are hosting several different websites (for different customers) and they are all calling on Flickr to grant permissions for my app to access their Flickr account (for posting, deleting photos and sets).  I'm using standard methods in the Flickr .net library.  All works fine if I have each customer get their own, fixed API key and tokens, but this isn't a scalable approach  I would rather I pass them to Flickr, let them authorize or decline, then return them with the FROB/token in the URL to their site.  Problem is I can only seem to set up one static Callback URL with Flickr at the app level.  I'd rather not use this but instead pass the appropriate Callback URL with the authorization request, but I see no way to do that.  Any clues?

Coordinator
Aug 20, 2011 at 9:27 PM

Two choices.

1) Pass a parameter called "extra" along with the authentication url. This could be your 'real' callback URL. This would require you to have a central callback url for the API key, and then that would forward it to the specific app based on the "extra" parameter.

2) Switch to the OAuth authentication, where the callback URL is specified as a parameter to the authentication methods, and overrides the Flickr setting.

Unfortunately I haven't finished implementing OAuth in the FlickrNet library yet, although it is almost finished.

Sam

Aug 20, 2011 at 11:17 PM

Sam:  Thanks.  I've created a common landing page (to use for the static Flickr callback URL setting) and will do a redirect from there using a custom URL I'll build and store in a session variable before sending the user off to Flickr to authenticate.

And thanks for answering my second question (when the FlickrNet library will be modernized for OAuth) before I even asked!

Take care..Thanks, again.

Aug 21, 2011 at 12:35 AM

Sam:  One more question...do you have any sample code to demonstrate passing of the 'extra' parameter?  And are you saying it will be returned, essentially appended to the URL after the FROB, in the response from Flickr?

Coordinator
Aug 21, 2011 at 8:12 AM

Yes, that's exactly what happens.

string url = AuthCalcWebUrl(Perms.Write);

url += "&extra=App1";

Response.Redirect(url);

and then this will get passed back as Request.QueryString["extra"] along with the frob.

Sam

Aug 21, 2011 at 4:33 PM

Thanks, I guess you meant 'extra' quite literally.  I appended it to the request, send the user off to Flickr, they authenticate, but then I get this error (below) thrown on the Flickr side before returning to my callback URL.  Any ideas?

// begin Flickr error message

Oops! The API key or signature is invalid.

An external application has requested your login credentials and permission to perform certain actions on your behalf, but has failed to include all the required data.

You don't really need to know what this means, except that you can't use the application until this problem is fixed. (It's a third-party problem, not a Flickr problem.)

There are lots of applications using the Flickr API. If you are curious about this, visit the Flickr Services page to see more examples of cool stuff. Otherwise, you might like to head to your home page...

// end Flickr error message

Coordinator
Aug 22, 2011 at 1:59 PM

Ah yes, the extra parameter needs to be included in the api_sig calculation - I'd forgotten that.

I've added it to the latest source. In the mean time you could copy that particular method and use it instead.

http://flickrnet.codeplex.com/SourceControl/changeset/view/92027#1499700

Sam

Aug 22, 2011 at 3:43 PM

Sam:  Thanks.  I was reluctant to part ways with the baked-in methods in the library to get this to work.  I hadn't realized you updated the source code to handle the change to the api-sig.  Thanks for posting that bit...I'll likely snip it and use the method independently...