def oauth_enabled(decorated_function=None, scopes=None, **decorator_kwargs):
 def curry_wrapper(wrapped_function):
  @wraps(wrapped_function)
  def enabled_wrapper(request, *args, **kwargs):
   return_url = decorator_kwargs.pop('return_url', request.get_full_path())
   user_oauth = django_util.UserOAuth2(request, scopes, return_url)
   setattr(request, django_util.oauth2_settings.request_prefix, user_oauth)
   return wrapped_function(request, *args, **kwargs)
  return enabled_wrapper
 if decorated_function:
  return curry_wrapper(decorated_function)
 else:
  return curry_wrapper

def oauth_enabled ( decorated_function = None , scopes = None , ** decorator_kwargs ) : def curry_wrapper ( wrapped_function ) : @ wraps ( wrapped_function ) def enabled_wrapper ( request , * args , ** kwargs ) : return_url = decorator_kwargs . pop ( 'return_url' , request . get_full_path ( ) ) user_oauth = django_util . UserOAuth2 ( request , scopes , return_url ) setattr ( request , django_util . oauth2_settings . request_prefix , user_oauth ) return wrapped_function ( request , * args , ** kwargs ) return enabled_wrapper if decorated_function : return curry_wrapper ( decorated_function ) else : return curry_wrapper
decorator to enable oauth credentials if authorized .