Get a set of all the authorized scopes according to the handlers.
977420
def _collect_scopes(handlers, scopes, user, client):
    
    results = set()

    data = {'user': user, 'client': client}

    def visitor(scope_name, func):
        claim_names = func(data)
        # If the claim_names is None, it means that the scope is not authorized.
        if claim_names is not None:
            results.add(scope_name)

    _visit_handlers(handlers, visitor, 'scope', scopes)

    return results
570336
def get_default_credentials(scopes):
    """"""
    credentials, _ = google.auth.default(scopes=scopes)
    return credentials
645398
def tasks_in_scope(scope)
      prefix = scope.path
      tasks.select { |t|
        /^#{prefix}:/ =~ t.name
      }
    end
868110
public List<String> iterateScopeNameList() {
        log.debug("iterateScopeNameList called");
        Collection<IScope> scopes = getScopes();
        log.debug("Scopes: {}", scopes.size());
        List<String> scopeNames = new ArrayList<String>(scopes.size());
        for (IScope scope : scopes) {
            log.debug("Client scope: {}", scope);
            scopeNames.add(scope.getName());
            if (log.isDebugEnabled()) {
                for (Map.Entry<String, Object> entry : scope.getAttributes().entrySet()) {
                    log.debug("Client scope attr: {} = {}", entry.getKey(), entry.getValue());
                }
            }
        }
        return scopeNames;
    }
1263122
def handlers(self):
        """"""
        used = []
        for base_url, mapping in self.routes.items():
            for url, methods in mapping.items():
                for method, versions in methods.items():
                    for version, handler in versions.items():
                        if not handler in used:
                            used.append(handler)
                            yield handler
249041
String getScopeForAuthorization()
    {
        if ( !scopeInAuthorization ) {
            return null;
        }

        StringBuilder sb = new StringBuilder();
        for ( String perm : appInfo.getScope() ) {
            sb.append( perm ).append( scopePermsSeparator );
        }

        return new String( sb.deleteCharAt( sb.length() - 1 ) );
    }
981552
public static Map<Key<?>, Binding<?>> findBindingsInScope(Injector injector, Scope... scopes) {
    Map<Key<?>,Binding<?>> bindings = new LinkedHashMap<Key<?>, Binding<?>>();
    ALL_BINDINGS: for( Map.Entry<Key<?>, Binding<?>> entry : injector.getAllBindings().entrySet() ) {
      for( Scope scope : scopes ) {
        if( inScope(injector, entry.getValue(), scope )) {
          bindings.put(entry.getKey(), entry.getValue());
          continue ALL_BINDINGS;
        }
      }
    }
    return bindings;
  }
56003
def _ScopesFromMetadataServer(self, scopes):
        """"""
        if not util.DetectGce():
            raise exceptions.ResourceUnavailableError(
                'GCE credentials requested outside a GCE instance')
        if not self.GetServiceAccount(self.__service_account_name):
            raise exceptions.ResourceUnavailableError(
                'GCE credentials requested but service account '
                '%s does not exist.' % self.__service_account_name)
        if scopes:
            scope_ls = util.NormalizeScopes(scopes)
            instance_scopes = self.GetInstanceScopes()
            if scope_ls > instance_scopes:
                raise exceptions.CredentialsError(
                    'Instance did not have access to scopes %s' % (
                        sorted(list(scope_ls - instance_scopes)),))
        else:
            scopes = self.GetInstanceScopes()
        return scopes
250813
def _get_scope_with_mangled(self, name):
        """"""
        scope = self
        while True:
            parent = scope.get_enclosing_scope()
            if parent is None:
                return

            if name in parent.rev_mangled:
                return parent

            scope = parent
201637
public void setScopes(Set<ApiAppOauthScopeType> scopes) {
        if (oauth == null) {
            oauth = new ApiAppOauth();
        }
        oauth.setScopes(scopes);
    }
765186
public Set<String> getBasicScopeNames(ScopeType type) {
        if (type != null) {
            Set<String> names = new HashSet<String>();
            for (IBasicScope child : children.keySet()) {
                if (child.getType().equals(type)) {
                    names.add(child.getName());
                }
            }
            return names;
        }
        return getScopeNames();
    }
1315380
private Set<ISharedObjectSecurity> getSecurityHandlers() {
        ISharedObjectSecurityService security = (ISharedObjectSecurityService) ScopeUtils.getScopeService(getParent(), ISharedObjectSecurityService.class);
        if (security == null) {
            return null;
        }
        return security.getSharedObjectSecurity();
    }
142291
@JsonIgnore
	public Collection<? extends GrantedAuthority> getAuthorities() {
		if (user.isAdmin()) {
			return Collections.singleton(new SimpleGrantedAuthority(Roles.ADMIN.toString()));
		} else if (user.isModerator()) {
			return Collections.singleton(new SimpleGrantedAuthority(Roles.MOD.toString()));
		} else {
			return Collections.singleton(new SimpleGrantedAuthority(Roles.USER.toString()));
		}
	}
787519
protected boolean validateResourceSetScopes(final ResourceSet rs) {
        if (rs.getPolicies() == null || rs.getPolicies().isEmpty()) {
            return true;
        }
        return rs.getPolicies()
            .stream()
            .flatMap(policy -> policy.getPermissions().stream())
            .allMatch(permission -> rs.getScopes().containsAll(permission.getScopes()));
    }
619421
public Set<Handler> getHandlers() {
        modificationLock.readLock().lock();
        try {
            return new HashSet<>(handlers);
        } finally {
            modificationLock.readLock().unlock();
        }
    }
96968
def _GetGsScopes(self):
    """"""
    service_accounts = self.watcher.GetMetadata(metadata_key=self.metadata_key)
    try:
      scopes = service_accounts[self.service_account]['scopes']
      return list(GS_SCOPES.intersection(set(scopes))) if scopes else None
    except KeyError:
      return None
622907
def p_scope(p):
    """'"""
    slist = p[4]
    scopes = OrderedDict()
    for i in ('CLASS',
              'ASSOCIATION',
              'INDICATION',
              'PROPERTY',
              'REFERENCE',
              'METHOD',
              'PARAMETER',
              'ANY'):
        scopes[i] = i in slist
    p[0] = scopes