import foauth.providers


class Flickr(foauth.providers.OAuth1):
    # General info about the provider
    provider_url = 'http://www.flickr.com/'
    docs_url = 'http://www.flickr.com/services/api/'
    category = 'Pictures'

    # URLs to interact with the API
    request_token_url = 'http://www.flickr.com/services/oauth/request_token'
    authorize_url = 'http://www.flickr.com/services/oauth/authorize'
    access_token_url = 'http://www.flickr.com/services/oauth/access_token'
    api_domain = 'api.flickr.com'

    available_permissions = [
        # (None, 'access only your public photos'),
        # ('read', 'access your public and private photos'),
        # ('write', 'upload, edit and replace your photos'),
        ('delete', 'upload, edit, replace and delete your photos'),
    ]

    https = False

    def get_authorize_params(self, redirect_uri):
        params = super(Flickr, self).get_authorize_params(redirect_uri)
        params['perms'] = self.available_permissions[0][0]
        return params

    def get_user_id(self, key):
        url = u'/services/rest/?method=flickr.people.getLimits'
        url += u'&format=json&nojsoncallback=1'
        r = self.api(key, self.api_domain, url)
        return r.json[u'person'][u'nsid']

@@ -549,18 +549,16 @@
 %0A       
- #
  (None, 
@@ -599,18 +599,16 @@
 %0A       
- #
  ('read'
@@ -658,18 +658,16 @@
 %0A       
- #
  ('write
@@ -783,16 +783,49 @@
 ),%0A    %5D
+%0A    permissions_widget = 'radio'
 %0A%0A    ht
@@ -884,16 +884,24 @@
 rect_uri
+, scopes
 ):%0A     
@@ -969,68 +969,83 @@
 _uri
-)%0A        params%5B'perms'%5D = self.available_permission
+, scopes)%0A%0A        if any(scopes):%0A            params%5B'perms'%5D = scope
 s%5B0%5D
-%5B0%5D
+%0A
 %0A   

Rewrite Flickr to use the new scope selection system