GithubHelp home page GithubHelp logo

guniorobot / gae-flickrapp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from straup/gae-flickrapp

1.0 2.0 0.0 160 KB

FlickrApp is a simple base class to use with Google App Engine (GAE) packages that allows you to use Flickr as a Single Sign On (SSO) provider and validation service.

Python 100.00%

gae-flickrapp's Introduction

FlickrApp

  FlickrApp is a simple base class to use with Google App Engine (GAE)
  packages that allows you to use Flickr as a Single Sign On (SSO)
  provider and validation service. As an extra bonus you get a Flickr
  API Auth token in the process!
  
  Currently this class is designed (and tested) to work with the plain
  vanilla GAE/Django development environment. The next step is to ensure
  that is works with the AppDrop GAE/EC2 container.
  
CLASS METHODS
  
  __init__(self, api_key, api_secret)
      Create a new FlickrApp object.
      
      Remember, this class is not meant to be used on it's own. Rather
      it is a base class that you subclass in your own application. For
      example:
      
          class MyFlickrApp (FlickrApp) :
      
            def init (self) :
              api_key = "this part is left to you"
              api_secret = "to squirt in to your application"
      
              FlickrApp.__init__(self, api_key, api_secret)
  
OBJECT METHODS YOU SHOULD CARE ABOUT

  check_logged_in(self, min_perms=None)
      Check to see if the current user is logged in. If not, force
      them to re-authenticate your application via the Flickr API
      Auth flow.
      
      Logged in is defined as having valid 'ffo' and 'fft' cookies.
      
      'ffo' cookies are constantly renewed for 30 days with each page
      view and map the current user to a user in the FlickrUser database.
      If the cookie is not present or does not validate this method
      returns False.
      
      'fft' cookies last the duration of the browser session and are
      used to ensure that the user has a token with a minimum permissions
      set. This is done by calling the flickr.auth.checkToken method. If
      the token does not match this method returns False.
      
      If both cookies validate, the object's 'user' key will be set and
      the method will return True.
      
      For example:
      
          class MyHandler (FlickrApp) :
      
            # Assume __init__ here...
            
            def get (self) :
              min_perms = 'read'
      
              if not self.check_logged_in(min_perms) :
                self.do_flickr_auth(min_perms)
                return
      
              self.response.out.write("Hi there %s" % self.user.username)

  do_flickr_auth(self, min_perms=None)
      This method will generate and redirect the user to the Flickr
      API Auth endpoint where the user will be prompted to approve
      your request for a Flickr token (with 'min_perms' permissions).
  
  do_token_dance(self, perms=None)
      This is the method you should call from your 'auth' handler; that
      is the URL that you tell the Flickr API Auth flow to redirect to
      once a user has authed your application (in magic Flickr land).
      
      It will check for a 'frob' parameter and then call the Flickr API
      and exchange it for a valid Flickr Auth token.
      
      If something goes wrong it will return False, otherwise it will
      redirect the user to your application's root URL (where presumably
      you are calling 'checked_logged_in').
      
      For example:
      
          class TokenFrobHandler (FlickrApp) :
      
              # Assume __init__ here
        
              def get (self):  
                  try :
                      self.do_token_dance() :
                  except Exception, e :
                      self.response.out.write("OH NOES! SOMETHING WENT WRONG!")

EVERYTHING ELSE

Everything is a bit up in the air still. The documentation will be updated when
the dust settles.
  
REQUIREMENTS

  Just the Google AppEngine (GAE) package itself.

gae-flickrapp's People

Contributors

thisisaaronland avatar tominsam avatar

Stargazers

Gun.io Robot avatar

Watchers

Gun.io Robot avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.