 
 angular.module 'flickrSimpleReorder'
 .provider 'Auth', ->
-  $.cookie.json = true;
+  config = this
 
   @authUrl = 'http://flickr.com/services/auth/'
   @getTokenUrl = 'https://api.flickr.com/services/rest/'

    sig = @sigMethod strToSign
    "#{convertedUrl}api_sig=#{sig}"

  _auth = $.cookie 'auth'

  @$get = [ '$http', ($http) =>
    exports =
      signUrl: @signUrl

      authUrl: => @signUrl @authUrl,
        perms: @perms
      , 'login'

      getToken: (frob) =>
        url = @signUrl @getTokenUrl,
          method: 'flickr.auth.getToken'
          frob: frob
        , 'token'
        $http.get(url)

      clearAuth: =>
        _auth = {}
        $.removeCookie 'auth'

      setAuth: (auth) =>
        _auth =
          perms: auth.perms._content
          token: auth.token._content
          user: auth.user
        $.cookie 'auth', _auth,
          expires: 30

    Object.defineProperties exports,
      perms:
        get: -> _auth.perms
      token:
        get: -> _auth.token
      user:
        get: -> _auth.user

    exports
  ]

      else
        params.format ||= @format unless _.isEmpty @format
        params.nojsoncallback ||= 1
        params.auth_token = _token

    _(params).pairs().sortBy(0).forEach (param) ->
      strToSign += param[0] + param[1]
