def _wrapped_view(request, *args, **kwargs):
            if canvas:
                oauth_url, redirect_uri = generate_oauth_url(
                    scope_list, extra_params=extra_params)
            else:
                oauth_url, redirect_uri = get_oauth_url(
                    request, scope_list, extra_params=extra_params)

            try:
                # call get persistent graph and convert the
                # token with correct redirect uri
                get_persistent_graph(request, redirect_uri=redirect_uri)
                return view_func(request, *args, **kwargs)
            except open_facebook_exceptions.OpenFacebookException, e:
                if test_permissions(request, scope_list, redirect_uri):
                    # an error if we already have permissions
                    # shouldn't have been caught
                    # raise to prevent bugs with error mapping to cause issues
                    raise
                else:
                    logger.info(
                        u'requesting access with redirect uri: %s, error was %s',
                        redirect_uri, e)
                    response = response_redirect(oauth_url, canvas=canvas)
                    return response
Example #2
0
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, current_uri, redirect_uri = get_oauth_url(
         request, scope_list,
         extra_params=extra_params)
     try:
         # call get persistent graph and convert the
         # token with correct redirect uri
         get_persistent_graph(request, redirect_uri=current_uri)
         #Note we're not requiring a persistent graph here
         #You should require a persistent graph in the view when you start using this
         return view_func(request, *args, **kwargs)
     except open_facebook_exceptions.OpenFacebookException, e:
         permission_granted = test_permissions(
             request, scope_list, current_uri)
         if permission_granted:
             # an error if we already have permissions
             # shouldn't have been caught
             # raise to prevent bugs with error mapping to cause issues
             raise
         else:
             logger.info(
                 u'requesting access with redirect uri: %s, error was %s',
                 redirect_uri, e)
             response = response_redirect(oauth_url, canvas=canvas)
             return response
Example #3
0
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, redirect_uri = get_oauth_url(request,
                                             scope_list,
                                             extra_params=extra_params)
     try:
         # call get persistent graph and convert the
         # token with correct redirect uri
         get_persistent_graph(request, redirect_uri=redirect_uri)
         #Note we're not requiring a persistent graph here
         #You should require a persistent graph in the url when you start using this
         return view_func(request, *args, **kwargs)
     except open_facebook_exceptions.OpenFacebookException, e:
         permission_granted = test_permissions(request, scope_list,
                                               redirect_uri)
         if permission_granted:
             # an error if we already have permissions
             # shouldn't have been caught
             # raise to prevent bugs with error mapping to cause issues
             raise
         else:
             logger.info(
                 u'requesting access with redirect uri: %s, error was %s',
                 redirect_uri, e)
             response = response_redirect(oauth_url, canvas=canvas)
             return response
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, redirect_uri = get_oauth_url(request, scope_list)
     if test_permissions(request, scope_list, redirect_uri):
         return view_func(request, *args, **kwargs)
     else:
         logger.info("requesting access with redirect uri: %s", redirect_uri)
         response = response_redirect(oauth_url, canvas=canvas)
         return response
Example #5
0
 def oauth_redirect(self, oauth_url, redirect_uri, e=None):
     '''
     Redirect to Facebook's oAuth dialog
     '''
     logger.info(
         u'requesting access with redirect uri: %s, error was %s',
         redirect_uri, e)
     response = response_redirect(oauth_url, canvas=self.canvas)
     return response
Example #6
0
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, redirect_uri = get_oauth_url(request, scope_list)
     if test_permissions(request, scope_list, redirect_uri):
         return view_func(request, *args, **kwargs)
     else:
         logger.info('requesting access with redirect uri: %s',
                     redirect_uri)
         response = response_redirect(oauth_url, canvas=canvas)
         return response
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, redirect_uri = get_oauth_url(request, scope_list)
     if test_permissions(request, scope_list, redirect_uri):
         return view_func(request, *args, **kwargs)
     else:
         logger.info('requesting access with redirect uri: %s', redirect_uri)
         _canvas = canvas # Bring into local scope
         if _canvas is None:
             _canvas = getattr(request, 'fb_info', {}).get('is_canvas', False)
         response = response_redirect(oauth_url, canvas=_canvas)
         return response
Example #8
0
    def oauth_redirect(self, oauth_url, redirect_uri, e=None):
        """
        Redirect to Facebook's oAuth dialog
        """
        logger.info(u"requesting access with redirect uri: %s, error was %s", redirect_uri, e)

        # for internal Facebook pages we should use a script to redirect
        script_redirect = False
        if self.canvas or self.page_tab:
            script_redirect = True

        # redirect using HTTP headers or a script
        response = response_redirect(oauth_url, script_redirect=script_redirect)
        return response
Example #9
0
    def oauth_redirect(self, oauth_url, redirect_uri, e=None):
        '''
        Redirect to Facebook's oAuth dialog
        '''
        logger.info(u'requesting access with redirect uri: %s, error was %s',
                    redirect_uri, e)

        # for internal Facebook pages we should use a script to redirect
        script_redirect = False
        if self.canvas or self.page_tab:
            script_redirect = True

        # redirect using HTTP headers or a script
        response = response_redirect(oauth_url,
                                     script_redirect=script_redirect)
        return response
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, redirect_uri = get_oauth_url(request, scope_list, extra_params=extra_params)
     try:
         # call get persistent graph and convert the
         # token with correct redirect uri
         get_persistent_graph(request, redirect_uri=redirect_uri)
         return view_func(request, *args, **kwargs)
     except open_facebook_exceptions.OpenFacebookException, e:
         if test_permissions(request, scope_list, redirect_uri):
             # an error if we already have permissions
             # shouldn't have been caught
             # raise to prevent bugs with error mapping to cause issues
             raise
         else:
             logger.info(u"requesting access with redirect uri: %s, error was %s", redirect_uri, e)
             response = response_redirect(oauth_url, canvas=canvas)
             return response
Example #11
0
 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)
         
         #Normal facebook errors should be raised
         #OAuthException s should cause a redirect for authorization
         try:
             permission_granted = test_permissions(request, scope_list, redirect_uri)
         except open_facebook_exceptions.OAuthException, e:
             permission_granted = False
         
         if permission_granted:
             return view_func(request, *args, **kwargs)
         else:
             logger.info('requesting access with redirect uri: %s',
                         redirect_uri)
             response = response_redirect(oauth_url, canvas=canvas)
             return response
 def _wrapped_view(request, *args, **kwargs):
     oauth_url, redirect_uri = get_oauth_url(request, scope_list, extra_params=extra_params)
     try:
         ## Call get_persistent_graph() and convert the
         ## token with correct redirect URI
         get_persistent_graph(request, redirect_uri=redirect_uri)
         return view_func(request, *args, **kwargs)
     except open_facebook_exceptions.OpenFacebookException, e:
         if test_permissions(request, scope_list, redirect_uri):
             ## An error if we already have permissions
             ## shouldn't have been caught
             ## raise to prevent bugs with error mapping to cause issues
             raise
         else:
             logger.info(u'Requesting access with redirect_uri: %s, error was %s', redirect_uri, e)
             _canvas = canvas # Bring into local scope
             if _canvas is None:
                 _canvas = getattr(request, 'fb_info', {}).get('is_canvas', False)
             response = response_redirect(oauth_url, canvas=_canvas)
             return response
Example #13
0
    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)

            #Normal facebook errors should be raised
            #OAuthException s should cause a redirect for authorization
            try:
                permission_granted = test_permissions(request, scope_list,
                                                      redirect_uri)
            except open_facebook_exceptions.OAuthException, e:
                permission_granted = False

            if permission_granted:
                return view_func(request, *args, **kwargs)
            else:
                logger.info('requesting access with redirect uri: %s',
                            redirect_uri)
                response = response_redirect(oauth_url, canvas=canvas)
                return response