Commits

Alexis Metaireau committed 068be30

bugfixes

  • Participants
  • Parent commits b1df5b4

Comments (0)

Files changed (3)

oauthclient/models.py

     def get_authorize_url(self):
         return self.server_url + self.authorize_url
 
+    def __unicode__(self):
+        return u'Server : %s' % self.server_url
+
+    class Meta:
+        verbose_name = "OAuth Server"
+
 
 class ConsumerToken(models.Model):
     """Define a couple key-secret provided by the oauth server for this
     server = models.ForeignKey(OAuthServer)
     last_modification = models.DateField(auto_now=True)
 
+    def __unicode__(self):
+        return 'Token : %s' % self.identifier
+
     def get_consumer(self):
         """Return a consumer object, configured with settings values.
         

oauthclient/utils.py

     already exists.
     
     """
-    return not (identifier + 'oauth_token' and identifier + 'oauth_token_secret' in request.session)
+    return not (identifier + '_oauth_token' and identifier + '_oauth_token_secret' in request.session)
     
 def is_oauthenticated(identifier, force=False):
     """Decorator when oauth authentication is needed.
             if force or oauth_need_authentication(request=request,
                     identifier=identifier, force=force):
                 return redirect('%s?next=%s' % (
-                    reverse('oauth:request_token', kwargs={'identifier':identifier}), 
+                    reverse('oauth:request_token'), 
                     request.path))
             else:
                 return func(*args, **kwargs)

oauthclient/views.py

     request.session[identifier + '_request_token_secret'] = request_token['oauth_token_secret']
     
     #redirect the user to the authentication page
-    callback_url = 'http://%s%s' % (Site.objects.get_current().domain,
-        reverse('oauth:access_token_ready', args=[identifier]))
+    callback_url = 'http://%s%s' % (
+        Site.objects.get_current().domain, 
+        reverse('oauth:access_token_ready'))
     
     redirect_url = "%s?oauth_token=%s&oauth_callback=%s" % (
         token.server.get_authorize_url(), 
     request_token = oauth2.Token(request.session[identifier + '_request_token'],
         request.session[identifier + '_request_token_secret'])
     request_token.set_verifier(request.GET['oauth_verifier'])
-    client = oauth2.Client(_get_consumer(), request_token)
+    client = oauth2.Client(token.get_consumer(), request_token)
     resp, content = client.request(token.server.get_access_token_url() , "POST")
     access_token = dict(urlparse.parse_qsl(content))