def oauth_required(decorated_function=None, scopes=None, **decorator_kwargs):
 def curry_wrapper(wrapped_function):
  @wraps(wrapped_function)
  def required_wrapper(request, *args, **kwargs):
   if (not ((django_util.oauth2_settings.storage_model is None) or request.user.is_authenticated())):
    redirect_str = '{0}?next={1}'.format(django.conf.settings.LOGIN_URL, parse.quote(request.path))
    return shortcuts.redirect(redirect_str)
   return_url = decorator_kwargs.pop('return_url', request.get_full_path())
   user_oauth = django_util.UserOAuth2(request, scopes, return_url)
   if (not user_oauth.has_credentials()):
    return shortcuts.redirect(user_oauth.get_authorize_redirect())
   setattr(request, django_util.oauth2_settings.request_prefix, user_oauth)
   return wrapped_function(request, *args, **kwargs)
  return required_wrapper
 if decorated_function:
  return curry_wrapper(decorated_function)
 else:
  return curry_wrapper

def oauth_required ( decorated_function = None , scopes = None , ** decorator_kwargs ) : def curry_wrapper ( wrapped_function ) : @ wraps ( wrapped_function ) def required_wrapper ( request , * args , ** kwargs ) : if ( not ( ( django_util . oauth2_settings . storage_model is None ) or request . user . is_authenticated ( ) ) ) : redirect_str = '{0}?next={1}' . format ( django . conf . settings . LOGIN_URL , parse . quote ( request . path ) ) return shortcuts . redirect ( redirect_str ) return_url = decorator_kwargs . pop ( 'return_url' , request . get_full_path ( ) ) user_oauth = django_util . UserOAuth2 ( request , scopes , return_url ) if ( not user_oauth . has_credentials ( ) ) : return shortcuts . redirect ( user_oauth . get_authorize_redirect ( ) ) setattr ( request , django_util . oauth2_settings . request_prefix , user_oauth ) return wrapped_function ( request , * args , ** kwargs ) return required_wrapper if decorated_function : return curry_wrapper ( decorated_function ) else : return curry_wrapper
decorator to require oauth2 credentials for a view .