Constructs a new instance using OAuth 2.0 scopes.

@param context context
@param scopes non empty OAuth 2.0 scope list
@return new instance

@since 1.15
973499
public static GoogleAccountCredential usingOAuth2(Context context, Collection<String> scopes) {
    Preconditions.checkArgument(scopes != null && scopes.iterator().hasNext());
    String scopesStr = "oauth2: " + Joiner.on(' ').join(scopes);
    return new GoogleAccountCredential(context, scopesStr);
  }
63122
public void changeScope(@Nullable final ThreadDelegatedContext context)
    {
        final ThreadDelegatedContext oldContext = threadLocal.get();
        if (oldContext != null) {
            if (oldContext == context) {
                // If the context gets exchanged with itself, do nothing.
                return;
            }
            else {
                // This must not clear the context. It might still be
                // referenced by another thread.
                oldContext.event(ScopeEvent.LEAVE);
            }
        }

        if (context != null) {
            threadLocal.set(context);
            context.event(ScopeEvent.ENTER);
        }
        else {
            threadLocal.remove();
        }
    }
905216
public function oauthAuthenticate(HTTPRequest $request, $scopes = [])
    {
        $headers = $request->getHeaders();

        // must have a client
        if (empty($headers['oauth_client_id'])) {
            return false;
        }

        // if scopes passed, check request contains all the scopes
        if (!empty($scopes)) {
            $matchedScopes = [];

            $requestScopes = !empty($headers['oauth_scopes']) ?
                explode(',', $headers['oauth_scopes']) :
                [];

            // if request has no scopes then authentication failed
            if (empty($requestScopes)) {
                return false;
            }

            foreach ($scopes as $scope) {
                $matchedScopes[] = in_array($scope, $requestScopes);
            }

            return (bool)min($matchedScopes);
        }

        return true;
    }
1081003
def get_auth_scope(cls, instance_config):
        
        auth_scope = instance_config.get('auth_scope')
        if not auth_scope:
            return None

        if not auth_scope.get('project'):
            raise IncompleteAuthScope()

        if auth_scope['project'].get('name'):
            # We need to add a domain scope to avoid name clashes. Search for one. If not raise IncompleteAuthScope
            if not auth_scope['project'].get('domain', {}).get('id'):
                raise IncompleteAuthScope()
        else:
            # Assume a unique project id has been given
            if not auth_scope['project'].get('id'):
                raise IncompleteAuthScope()

        return auth_scope
782415
public TypeUsage.Builder scope(QualifiedName scope) {
    this.scope = Objects.requireNonNull(scope);
    return (TypeUsage.Builder) this;
  }
83764
def _create_with_scope(body, kwargs):
    '''
    
    '''
    return ast.With(
        items=[
            ast.withitem(
                context_expr=_a.Call(
                    _a.Name('ContextScope'),
                    [_a.Name('context')],
                    keywords=kwargs,
                ),
                optional_vars=_a.Name('context', ctx=ast.Store())
            ),
        ],
        body=body,
    )
1123058
public static Set<String> parseRequestScopes(final HttpServletRequest context) {
        val parameterValues = context.getParameter(OAuth20Constants.SCOPE);
        if (StringUtils.isBlank(parameterValues)) {
            return new HashSet<>(0);
        }
        return CollectionUtils.wrapSet(parameterValues.split(" "));
    }
793874
public static List<InstanceModel> instances(BundleContext context) {
        List<InstanceModel> instances = new ArrayList<>();
        try {
            for (ServiceReference ref : context.getServiceReferences(Architecture.class, null)) {
                instances.add(new InstanceModel((Architecture) context.getService(ref)));
            }
        } catch (InvalidSyntaxException e) { //NOSONAR
            // Ignore it.
        }
        return instances;
    }
1063669
ProcScope createScope(Scope scope) {
        ProcScope created = scopes.get(scope);
        if (created == null) {
            created = new ProcScope(scope.getName());
            scopes.put(scope, created);
            created.setStrong(scope.isStrong());
            created.setIgnoreText(scope.isIgnoreText());
            if (scope.getParent() != null) {
                created.setParent(createScope(scope.getParent()));
            }
            Set<ProcCode> scopeCodes = new HashSet<ProcCode>();
            for (Code code : scope.getCodes()) {
                scopeCodes.add(createCode(code));
            }
            created.setScopeCodes(scopeCodes);
            created.setMin(scope.getMin());
            created.setMax(scope.getMax());
        }
        return created;
    }
760649
public function createToken($owner, $client, array $scopes = []): AccessToken
    {
        if (empty($scopes)) {
            $scopes = $this->scopeService->getDefaultScopes();
        } else {
            $this->validateTokenScopes($scopes);
        }

        do {
            $token = AccessToken::createNewAccessToken(
                $this->serverOptions->getAccessTokenTtl(),
                $owner,
                $client,
                $scopes
            );
        } while ($this->tokenRepository->tokenExists($token->getToken()));

        return $this->tokenRepository->save($token);
    }
282832
def validate_scopes(self, request):
        
        if not request.scopes:
            request.scopes = utils.scope_to_list(request.scope) or utils.scope_to_list(
                self.request_validator.get_default_scopes(request.client_id, request))
        log.debug('Validating access to scopes %r for client %r (%r).',
                  request.scopes, request.client_id, request.client)
        if not self.request_validator.validate_scopes(request.client_id,
                                                      request.scopes, request.client, request):
            raise errors.InvalidScopeError(request=request)
626948
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public StatsTraceContext newClientContext() {
    return StatsTraceContext.newClientContext(CallOptions.DEFAULT, Attributes.EMPTY, emptyMetadata);
  }
201637
public void setScopes(Set<ApiAppOauthScopeType> scopes) {
        if (oauth == null) {
            oauth = new ApiAppOauth();
        }
        oauth.setScopes(scopes);
    }
436542
public ServerAccessToken createAccessToken(AccessTokenRegistration reg)
		throws OAuthServiceException {
		ServerAccessToken token = new BearerAccessToken(reg.getClient(), 3600L);
		
		List<String> scope = reg.getApprovedScope().isEmpty() ? reg.getRequestedScope() 
				                                              : reg.getApprovedScope();
		token.setScopes(convertScopeToPermissions(reg.getClient(), scope));
		token.setSubject(reg.getSubject());
		token.setGrantType(reg.getGrantType());
		
		at = token;
		
		return token;
	}
188260
public CMAPersonalAccessToken addScope(Scope scope) {
    if (scopes == null) {
      scopes = new ArrayList<Scope>();
    }

    scopes.add(scope);
    return this;
  }
1319369
public void requestOauthSession(String scopes, String team) throws Exception {
    if (sessionFactory == null) {
      sessionFactory = new OAuthSessionFactory(slackApi);
      sessionFactory.start();
    }

    HttpUrl authorizeUrl = sessionFactory.newAuthorizeUrl(scopes, team, session -> {
      initOauthSession(session);
      System.out.printf("session granted: %s\n", session);
    });

    System.out.printf("open this URL in a browser: %s\n", authorizeUrl);
  }
1327250
public static ServiceAccount of(String email, List<String> scopes) {
    return new ServiceAccount(email, scopes);
  }