Sharing technology, ideas, insights!
Call: +91 710 466 0336         Email: hello@sanisoft.com

Blog

Use Flickr desktop authentication in your web applications

When I first came across the question “How to use Flickr desktop authentication in web applications?” my reaction was “Why would you want to do that!!” A brief investigation revealed that there is a usability advantage with doing that. If you have used Flickr authentication for web applications you would know that you have to input a callback URL at Flickr for the process to complete. The authentication process is perfect/seamless for web apps which are not self hosted by end users, an example being Fluidr which allows you to comment, fav explored photos. However many end users are confused if you ask them to do this step – particularly true for a lot of WordPress users ;-) In these cases having desktop authentication work flow works better. Flickr API documentation does explain how to authenticate a desktop application do read it carefully but it can be a bit confusing to translate to a web application.

I will be using phpFlickr class for the code and will skip the part about applying for API key and how to select ‘Desktop Application‘ as the authentication type. I am also assuming that you have downloaded phpFlickr and placed where your scripts can find it.

The code works in two steps. The first step consists of requesting a frob and creating a link which when clicked will validate the requested frob and grant permissions for that frob. Lets see how the code will be for this step.

Have commented the code and it is pretty self explanatory. On to step 2, which is even more simple, you just have to convert the frob to a token.

The thing to remember here is that the token will continue to work as long as you do not make another auth_getFrob call. If you do get another frob you will have to validate the frob again – this is in fact the method to reset or renew a token. Lastly the code above is just to explain the process, it can be written a bit more elegantly in a single php file using some control structures – just do it!

Try it out and let me know how it goes :-)

About the Author

Dr. Tarique Sani is a pediatrician and forensic expert by education. He is a PHP programmer of 'wrote the book' caliber and has to his credit several very popular open source as well as commercial PHP projects. He leads a team of dynamic programmers at SANIsoft who have in-depth understanding of Web development tools and usability practices with strong developmental skills in PHP, MySQL/PostgreSQL, HTML, DHTML, Javascript, and Linux/Apache

Leave a Reply