Skip to content
Browse files

Fixed redirect_uri for canvas

  • Loading branch information...
1 parent d84867c commit 0b638960a388e93503969d59359a1e97100753e6 @per42 per42 committed Feb 23, 2012
Showing with 8 additions and 4 deletions.
  1. +2 −2 django_facebook/decorators.py
  2. +6 −2 django_facebook/utils.py
View
4 django_facebook/decorators.py
@@ -26,7 +26,7 @@ def facebook_required(view_func=None, scope=fb_settings.FACEBOOK_DEFAULT_SCOPE,
def actual_decorator(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
- oauth_url, redirect_uri = get_oauth_url(request, scope_list)
+ oauth_url, redirect_uri = get_oauth_url(request, scope_list, canvas=canvas)
if test_permissions(request, scope_list, redirect_uri):
return view_func(request, *args, **kwargs)
else:
@@ -59,7 +59,7 @@ def actual_decorator(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
oauth_url, redirect_uri = get_oauth_url(request, scope_list,
- extra_params=extra_params)
+ extra_params=extra_params, canvas=canvas)
try:
# call get persistent graph and convert the
# token with correct redirect uri
View
8 django_facebook/utils.py
@@ -46,7 +46,7 @@ def test_permissions(request, scope_list, redirect_uri=None):
return scope_allowed
-def get_oauth_url(request, scope, redirect_uri=None, extra_params=None):
+def get_oauth_url(request, scope, redirect_uri=None, extra_params=None, canvas=False):
'''
Returns the oauth url for the given request and scope
Request maybe shouldnt be tied to this function, but for now it seems
@@ -57,7 +57,11 @@ def get_oauth_url(request, scope, redirect_uri=None, extra_params=None):
query_dict = QueryDict('', True)
query_dict['scope'] = ','.join(scope)
query_dict['client_id'] = facebook_settings.FACEBOOK_APP_ID
- redirect_uri = redirect_uri or request.build_absolute_uri()
+ if not redirect_uri:
+ if canvas:
+ redirect_uri = facebook_settings.FACEBOOK_CANVAS_PAGE
+ else:
+ redirect_uri = request.build_absolute_uri()
# set attempt=1 to prevent endless redirect loops
if 'attempt=1' not in redirect_uri:

0 comments on commit 0b63896

Please sign in to comment.
Something went wrong with that request. Please try again.