Invokes the {@value TwitterConstants#TWITTER_ENDPOINT_VERIFY_CREDENTIALS} endpoint in order to obtain a value to use for
the user subject.

@param config
@param accessToken
@param accessTokenSecret
@return
558574
public Map<String, Object> verifyCredentials(SocialLoginConfig config, String accessToken, @Sensitive String accessTokenSecret) {

        String endpointUrl = config.getUserApi();
        try {
            SocialUtil.validateEndpointWithQuery(endpointUrl);
        } catch (SocialLoginException e) {
            return createErrorResponse("TWITTER_BAD_USER_API_URL", new Object[] { endpointUrl, TwitterLoginConfigImpl.KEY_userApi, config.getUniqueId(), e.getLocalizedMessage() });
        }

        tokenSecret = accessTokenSecret;
        requestMethod = "GET";

        // Create the Authorization header string necessary to authenticate the request
        String authzHeaderString = createAuthzHeaderForVerifyCredentialsEndpoint(endpointUrl, accessToken);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Authz header string: " + authzHeaderString);
        }

        return executeRequest(config, requestMethod, authzHeaderString, endpointUrl, TwitterConstants.TWITTER_ENDPOINT_VERIFY_CREDENTIALS, null);
    }
93192
public Authentication verifyAccessToken(String accessToken) throws InvalidTokenException, TokenExpiredException{
        CacheProvider cp = cp();

        Authentication authc = cp.get(accessToken);
        if(null != authc) {
            if(!authc.isExpired()) {
                return authc;
            }else{
                cp.remove(accessToken);
            }
        }

        boolean jwt = checkJwtToken(accessToken);
        if(jwt) {
            authc = tp().verifyJwtAccessToken(accessToken);
        }else{
            authc = tp().verifyBearerAccessToken(accessToken);
        }

        cp.put(accessToken, authc, authc.getExpires());

        return authc;
    }
29890
private String signAndCreateAuthzHeader(String endpointUrl, Map<String, String> parameters) {

        String signature = computeSignature(requestMethod, endpointUrl, parameters);
        parameters.put(TwitterConstants.PARAM_OAUTH_SIGNATURE, signature);

        String authzHeaderString = createAuthorizationHeaderString(parameters);
        return authzHeaderString;
    }
564606
public static CodeDecryptResult codeDecrypt(String accessToken, CodeDecrypt codeDecrypt) {
		return codeDecrypt(accessToken, JsonUtil.toJSONString(codeDecrypt));
	}
1010091
public function configForShareAddress($accessToken, $json = true)
    {
        if ($accessToken instanceof AccessTokenInterface) {
            $accessToken = $accessToken->getToken();
        }

        $params = [
            'appId'     => $this->merchant->app_id,
            'scope'     => 'jsapi_address',
            'timeStamp' => strval(time()),
            'nonceStr'  => uniqid(),
            'signType'  => 'SHA1',
        ];

        $signParams = [
            'appid'       => $params['appId'],
            'url'         => UrlHelper::current(),
            'timestamp'   => $params['timeStamp'],
            'noncestr'    => $params['nonceStr'],
            'accesstoken' => strval($accessToken),
        ];

        ksort($signParams);

        $params['addrSign'] = sha1(urldecode(http_build_query($signParams)));

        return $json ? json_encode($params) : $params;
    }
495867
@Sensitive
    public Map<String, Object> getAccessToken(HttpServletRequest request, HttpServletResponse response, SocialLoginConfig config) {
        TwitterEndpointServices twitter = getTwitterEndpointServices();
        twitter.setConsumerKey(config.getClientId());
        twitter.setConsumerSecret(config.getClientSecret());

        Map<String, String[]> params = request.getParameterMap();

        if (isMissingParameter(params, TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN)) {
            return null;
        }

        // oauth_token provided in request MUST match the request token obtained earlier
        String token = request.getParameter(TwitterConstants.PARAM_OAUTH_TOKEN);
        String cachedRequestToken = webUtils.getAndClearCookie(request, response, TwitterConstants.COOKIE_NAME_REQUEST_TOKEN);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Obtained token from request: [" + token + "], matching against: [" + cachedRequestToken + "]");
        }

        if (!token.equals(cachedRequestToken)) {
            Tr.error(tc, "TWITTER_TOKEN_DOES_NOT_MATCH");
            return null;
        }

        String oauthVerifier = request.getParameter(TwitterConstants.PARAM_OAUTH_VERIFIER);

        Map<String, Object> result = twitter.obtainAccessToken(config, cachedRequestToken, oauthVerifier);
        if (result == null || result.isEmpty()) {
            Tr.error(tc, "TWITTER_ERROR_OBTAINING_ENDPOINT_RESULT", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN });
            return null;
        }

        if (!isSuccessfulResult(result, TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN)) {
            return null;
        }

        // If result was successful, the result has already been verified to contain a non-empty access_token and access_token_secret
        return result;
    }
521419
protected function getSignature(string $url, array $params, string $method, string $accessTokenSecret = null):string{
		$parseURL = parse_url($url);

		if(!isset($parseURL['host']) || !isset($parseURL['scheme']) || !in_array($parseURL['scheme'], ['http', 'https'], true)){
			throw new ProviderException('getSignature: invalid url');
		}

		parse_str($parseURL['query'] ?? '', $query);

		$signatureParams = array_merge($query, $params);

		if(isset($signatureParams['oauth_signature'])){
			unset($signatureParams['oauth_signature']);
		}

		$key  = implode('&', Psr7\r_rawurlencode([$this->options->secret, $accessTokenSecret ?? '']));
		$data = Psr7\r_rawurlencode([
			strtoupper($method ?? 'POST'),
			$parseURL['scheme'].'://'.$parseURL['host'].($parseURL['path'] ?? ''),
			Psr7\build_http_query($signatureParams),
		]);

		return base64_encode(hash_hmac('sha1', implode('&', $data), $key, true));
	}
910683
function useAccessAuth() {
  return new Promise((resolve, reject) => {
    if (!defaults.accessToken) {
      reject(__generateFakeResponse__(0, '', {}, 'accessToken is missing for Access authentication'))
    }
    else {
      let details = {
        "token_type": "",
        "expires_in": 0,
        "appName": defaults.appName,
        "username": "",
        "role": "",
        "firstName": "",
        "lastName": "",
        "fullName": "",
        "regId": 0,
        "userId": null
      };
      var aToken = defaults.accessToken.toLowerCase().startsWith('bearer') ? defaults.accessToken : 'Bearer ' + defaults.accessToken;
      utils.storage.set('user', {
        token: {
          Authorization:  aToken,
          appName: defaults.appName
        },
        details: details
      });
      resolve(__generateFakeResponse__(200, 'OK', {}, details, {}));
    }
  });

}
235148
public static String credential(String accessKey, DateTime date, String region) {
    return accessKey + "/" + date.toString(DateFormat.SIGNER_DATE_FORMAT) + "/" + region + "/s3/aws4_request";
  }
642740
private static Credential getCredentialFromAccessTokenProvider(
      AccessTokenProvider accessTokenProvider, Collection<String> scopes)
      throws IOException, GeneralSecurityException {
    Preconditions.checkArgument(
        accessTokenProvider.getAccessToken() != null, "Access Token cannot be null!");
    GoogleCredential credential =
        GoogleCredentialWithAccessTokenProvider.fromAccessTokenProvider(
            Clock.SYSTEM, accessTokenProvider);
    // TODO: credential.createScoped does nothing at the moment, since
    //  GoogleCredentialWithAccessTokenProvider never sets the serviceAccountPrivateKey.
    //  The AccessTokenProvider interface does not provide a mechanism to return a private key,
    //  and scopes cannot be sent down to the AccessTokenProvider
    //  so they're essentially ignored at the moment.
    return credential.createScoped(scopes);
  }
1346303
public Observable<BackendUser> getUserFromAuthToken(final String authToken){
        return Observable.create(new Observable.OnSubscribe<BackendUser>() {
            @Override
            public void call(Subscriber<? super BackendUser> subscriber) {
                try{
                    setLoginState(LOGGING_IN);
                    logger.debug("getWebService(): " + getWebService());
                    logger.debug("getuserFromAuthToken: " + authToken);
                    ValidCredentials validCredentials = getWebService().getUserFromAuthToken(authToken).toBlocking().first();
                    if(validCredentials == null) throw new Exception("Null User Returned");

                    subscriber.onNext(setUser(validCredentials));
                }catch (Exception e){
                    setLoginState(LOGGED_OUT);
                    subscriber.onError(e);
                }
            }
        });
    }
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;
	}
366992
public static Configuration configureWithAzureAdTokenProvider(
            Configuration configuration,
            URI apiServer,
            TokenProvider azureAdTokenProvider) {

        configuration.setProperty(AZURE_AD_API_SERVER, apiServer.toString());
        configuration.setProperty(AZURE_AD_TOKEN_PROVIDER, azureAdTokenProvider);

        return configuration;
    }
1251356
private static AWSSecurityTokenService buildStsClient(Builder builder) throws
                                                                           IllegalArgumentException {
        /**
         * Passing two types of credential interfaces is not permitted
         */
        if (builder.longLivedCredentials != null && builder.longLivedCredentialsProvider != null) {
            throw new IllegalArgumentException(
                    "It is illegal to set both an AWSCredentials and an AWSCredentialsProvider for an " +
                    STSAssumeRoleSessionCredentialsProvider.class.getName());
        }

        AWSCredentialsProvider longLivedCredentialsProvider = null;
        if (builder.longLivedCredentials != null) {
            longLivedCredentialsProvider = new StaticCredentialsProvider(
                    builder.longLivedCredentials);
        } else if (builder.longLivedCredentialsProvider != null) {
            longLivedCredentialsProvider = builder.longLivedCredentialsProvider;
        }

        // Depending on which options are explicitly provided we have to call the right overloaded constructor so
        // defaults are properly applied.
        if (longLivedCredentialsProvider == null) {
            if (builder.clientConfiguration == null) {
                return new AWSSecurityTokenServiceClient();
            } else {
                return new AWSSecurityTokenServiceClient(builder.clientConfiguration);
            }
        } else {
            if (builder.clientConfiguration == null) {
                return new AWSSecurityTokenServiceClient(longLivedCredentialsProvider);
            } else {
                return new AWSSecurityTokenServiceClient(longLivedCredentialsProvider,
                                                         builder.clientConfiguration);
            }
        }
    }
738448
protected OAuthProviderToken createOAuthToken(ConsumerAuthentication authentication) {
    return getTokenServices().createUnauthorizedRequestToken(authentication.getConsumerDetails().getConsumerKey(),
                                                             authentication.getOAuthParameters().get(OAuthConsumerParameter.oauth_callback.toString()));
  }
536234
protected boolean isMissingParameter(Map<String, String[]> requestParams, String endpoint) {
        if (TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN.equals(endpoint)) {
            // Must have oauth_token and oauth_verifier parameters in order to send request to oauth/access_token endpoint
            if (!requestParams.containsKey(TwitterConstants.PARAM_OAUTH_TOKEN)) {
                Tr.error(tc, "TWITTER_REQUEST_MISSING_PARAMETER", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN, TwitterConstants.PARAM_OAUTH_TOKEN });
                return true;
            }
            if (!requestParams.containsKey(TwitterConstants.PARAM_OAUTH_VERIFIER)) {
                Tr.error(tc, "TWITTER_REQUEST_MISSING_PARAMETER", new Object[] { TwitterConstants.TWITTER_ENDPOINT_ACCESS_TOKEN, TwitterConstants.PARAM_OAUTH_VERIFIER });
                return true;
            }
        }
        return false;
    }
1190369
def get_access_token(oauth_verifier, request_token)
      params = {oauth_verifier: oauth_verifier}
      response = client(request_token.to_a).get_access_token(params)
      AccessToken.new(response[:oauth_token], response[:oauth_token_secret],
        response.reject { |key, value| [:oauth_token, :oauth_token_secret].include?(key) })
    end