Compute the name of the scope for oauth

        :param Resource resource: the resource manager
        :param str method: an http method
        :return str: the name of the scope
16024
def build_scope(resource, method):
        
        if ResourceList in inspect.getmro(resource) and method == 'GET':
            prefix = 'list'
        else:
            method_to_prefix = {'GET': 'get',
                                'POST': 'create',
                                'PATCH': 'update',
                                'DELETE': 'delete'}
            prefix = method_to_prefix[method]

            if ResourceRelationship in inspect.getmro(resource):
                prefix = '_'.join([prefix, 'relationship'])

        return '_'.join([prefix, resource.schema.opts.type_])
987388
def _call(self, resource_url, params=None):
        
        
        url = "%s%s" % (self._endpoint(), resource_url)
        if params:
            url += "?%s&%s" % (params, self._auth())
        else:
            url += "?%s" % self._auth()
        return requests.get(url)
21912
def protected_resource_view(scopes=None):
    
    if scopes is None:
        scopes = []

    def wrapper(view):
        def view_wrapper(request,  *args, **kwargs):
            access_token = extract_access_token(request)

            try:
                try:
                    kwargs['token'] = Token.objects.get(access_token=access_token)
                except Token.DoesNotExist:
                    logger.debug('[UserInfo] Token does not exist: %s', access_token)
                    raise BearerTokenError('invalid_token')

                if kwargs['token'].has_expired():
                    logger.debug('[UserInfo] Token has expired: %s', access_token)
                    raise BearerTokenError('invalid_token')

                if not set(scopes).issubset(set(kwargs['token'].scope)):
                    logger.debug('[UserInfo] Missing openid scope.')
                    raise BearerTokenError('insufficient_scope')
            except BearerTokenError as error:
                response = HttpResponse(status=error.status)
                response['WWW-Authenticate'] = 'error="{0}", error_description="{1}"'.format(
                    error.code, error.description)
                return response

            return view(request,  *args, **kwargs)

        return view_wrapper

    return wrapper
989955
def _method_scope(input_layer, name):
  """"""
  global _in_method_scope
  # pylint: disable=protected-access

  with input_layer.g.as_default(), \
       scopes.var_and_name_scope(
           None if _in_method_scope else input_layer._scope), \
       scopes.var_and_name_scope((name, None)) as (scope, var_scope):
    was_in_method_scope = _in_method_scope
    yield scope, var_scope
    _in_method_scope = was_in_method_scope
355064
def method_missing(method, *args, &block)
      load

      meth = method.to_s

      return get_embedded_resource(meth) if is_embedded?(meth)
      return get_linked_resource(meth) if is_link?(meth)
      return @_changed[meth[0...-1]] = args.first if meth.end_with?('=') and is_field?(meth[0...-1])
      return get_field_value(meth) if is_field?(meth)

      super(method, *args, &block)
    end
560510
def get_resource_url(self):
        

        name = self.__class__.resource_name
        url = self.__class__.rest_base_url()

        return "%s/%s" % (url, name)
190297
def check_scope(self, token, request):
        http_method = request.method
        if not hasattr(self, http_method):
            raise OAuthError("HTTP method is not recognized")
        required_scopes = getattr(self, http_method)
        # a None scope means always allowed
        if required_scopes is None:
            return True
        
        # for non iterable types
        if isinstance(required_scopes, six.string_types):
            if token.allow_scopes(required_scopes.split()):
                return [required_scopes]
            return []
        allowed_scopes = []
        try:
            for scope in required_scopes:
                if token.allow_scopes(scope.split()):
                    allowed_scopes.append(scope)
        except:
            raise Exception('Invalid required scope values')
        else:
            return allowed_scopes
385058
def method_id(self, api_info):
    """"""
    # This is done here for now because at __init__ time, the method is known
    # but not the api, and thus not the api name.  Later, in
    # ApiConfigGenerator.__method_descriptor, the api name is known.
    if api_info.resource_name:
      resource_part = '.%s' % self.__safe_name(api_info.resource_name)
    else:
      resource_part = ''
    return '%s%s.%s' % (self.__safe_name(api_info.name), resource_part,
                        self.__safe_name(self.name))
1337337
def get_method_name(resource, method_type):
        
        return '{}_{}'.format(method_type.lower(), resource.Meta.name.lower())
1095951
private String getPropertyName(Method method)
   {
      String result = method.getName();
      if (result.startsWith("get"))
      {
         result = result.substring(3);
      }
      return result;
   }
1330654
def get_method_name(method):
    

    name = get_object_name(method)
    if name.startswith("__") and not name.endswith("__"):
        name = "_{0}{1}".format(get_object_name(method.im_class), name)
    return name
1050682
def http_resource(self, method, url, params=None, data=None):
        

        url = urllib_parse.urljoin(self.url, url)
        url = url if url.endswith("/") else url + "/"

        headers = None

        if method.lower() in self.unsupported_methods:
            headers = {"X-HTTP-Method-Override": method.upper()}
            method = "POST"

        r = self.session.request(method, url, params=params, data=data, headers=headers)

        r.raise_for_status()

        return r
415361
protected static void lookupMethodResource(javax.naming.Context context,
            Object instance, Method method, String name)
            throws NamingException, IllegalAccessException, InvocationTargetException
    {

        if (!method.getName().startsWith("set")
                || method.getParameterTypes().length != 1
                || !method.getReturnType().getName().equals("void"))
        {
            throw new IllegalArgumentException("Invalid method resource injection annotation");
        }

        Object lookedupResource;

        if ((name != null) && (name.length() > 0))
        {
            // TODO local or global JNDI
            lookedupResource = context.lookup(JAVA_COMP_ENV + name);
        }
        else
        {
            // TODO local or global JNDI
            lookedupResource =
                    context.lookup(JAVA_COMP_ENV + instance.getClass().getName() + "/" + getFieldName(method));
        }

        boolean accessibility = method.isAccessible();
        method.setAccessible(true);
        method.invoke(instance, lookedupResource);
        method.setAccessible(accessibility);
    }
867092
def get_oauth_token_key_name(self, provider):
        
        for _provider in self.oauth_providers:
            if _provider["name"] == provider:
                return _provider.get("token_key", "oauth_token")
442115
def _call_method(request)
      params = request.params
      resource_obj = nil
      resource_id = nil

      request.each_resource do |name, id|
        unless resource_obj
          (resource_obj = _load_resource(request.version, name)) or
            _error!(Errors::NotFoundError)
        else
          mounted_resource = resource_obj.mounts[name] or
            _error!(Errors::NotFoundError)
          resource_obj = mounted_resource.new
        end

        params.merge!(resource_obj.id_param => id) if id
        resource_id = id
      end

      resource_obj.process(request.request_method, !!resource_id, params)
    end
1333336
def system_methodHelp(self, method_name: str)->str:
        
        method = None
        if method_name in self.funcs:
            method = self.funcs[method_name]
        elif self.instance is not None:
            try:
                method = resolve_dotted_attribute(
                    self.instance,
                    method_name,
                    self.allow_dotted_names
                )
            except AttributeError:
                pass
        if method is None:
            return ""
        else:
            return pydoc.getdoc(method)
827434
def _method(self, *args, **kwargs):
    
    yield self.resource_handler.handle(self.__resource_view_type__, *args, **kwargs)