Returns a new instance of a temporary token authorization request URL as
defined in <a
href="http://oauth.net/core/1.0a/#rfc.section.6.2.1">Consumer Directs the
User to the Service Provider</a>.

@param temporaryToken
@return
760868
public OAuthAuthorizeTemporaryTokenUrl new10aAuthorizationUrl(String temporaryToken) {
        OAuthAuthorizeTemporaryTokenUrl authorizationUrl =
                new OAuthAuthorizeTemporaryTokenUrl(getAuthorizationServerEncodedUrl());
        authorizationUrl.temporaryToken = temporaryToken;
        return authorizationUrl;
    }
51499
public Auth checkToken(OAuth1Token accessToken) throws FlickrException {
        return checkToken(accessToken.getToken(), accessToken.getTokenSecret());
    }
862843
public static CallCredentials bearerAuth(final String token) {
        final Metadata extraHeaders = new Metadata();
        extraHeaders.put(AUTHORIZATION_HEADER, BEARER_AUTH_PREFIX + token);
        return new StaticSecurityHeaderCallCredentials(extraHeaders);
    }
604610
public Authentication verifyIdToken(String idToken) throws InvalidTokenException, TokenExpiredException {
        CacheProvider cp = cp();
        Authentication authc = cp.get(idToken);
        if(null != authc) {
            if(!authc.isExpired()) {
                return authc;
            }else{
                cp.remove(idToken);
            }
        }
        
        //check is jwt token?
        boolean jwt = checkJwtToken(idToken);
        if(jwt) {
            authc = tp().verifyIdToken(idToken);
        }else{
            throw new InvalidTokenException("idToken is not and jwt token:"+idToken);
        }

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

        return authc;
    }
612460
public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException {
        TmdbParameters parameters = new TmdbParameters();

        if (!token.getSuccess()) {
            throw new MovieDbException(ApiExceptionType.AUTH_FAILURE, "Authorisation token was not successful!");
        }

        parameters.add(Param.TOKEN, token.getRequestToken());
        URL url = new ApiUrl(apiKey, MethodBase.AUTH).subMethod(MethodSub.SESSION_NEW).buildUrl(parameters);
        String webpage = httpTools.getRequest(url);

        try {
            return MAPPER.readValue(webpage, TokenSession.class);
        } catch (IOException ex) {
            throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get Session Token", url, ex);
        }
    }
533057
public TokenRequestBuilder getTokenEndPoint() {
        for (Authentication apiAuth : authentications.values()) {
            if (apiAuth instanceof RetryingOAuth) {
                RetryingOAuth retryingOAuth = (RetryingOAuth) apiAuth;
                return retryingOAuth.getTokenRequestBuilder();
            }
        }
        return null;
    }
433417
public JwtToken refreshToken(String token) {
        String refreshedToken;
        Date expireTime = generateExpirationDate();
        try {
            final Claims claims = getClaimsFromToken(token);
            claims.put(CLAIM_KEY_CREATED, expireTime.getTime());
            refreshedToken = build(claims, expireTime);
        } catch (Exception e) {
            log.error("refreshedToken jwt token error : {}", e.getMessage());
            refreshedToken = null;
        }
        return new JwtToken(refreshedToken, expireTime.getTime());
    }
661211
function tokenCredentials (authorization, secret, done) {
  var strategy = this
  var provider = strategy.provider
  var endpoint = strategy.endpoints.token
  var client = strategy.client
  var method = endpoint.method && endpoint.method.toLowerCase()
  var url = endpoint.url
  var header = endpoint.header || 'Authorization'
  var scheme = endpoint.scheme || 'OAuth'
  var accept = endpoint.accept || 'application/x-www-form-urlencoded'
  var key = client.oauth_consumer_key
  var signer = provider.oauth_signature_method || 'PLAINTEXT'
  var verifier = authorization.oauth_verifier || null
  var token = authorization.oauth_token
  var params = {}

  // Initialize request
  var req = request[method || 'post'](url)

  // Build request parameters
  params.oauth_consumer_key = key
  params.oauth_signature_method = signer
  params.oauth_timestamp = timestamp()
  params.oauth_nonce = nonce(32)
  params.oauth_token = token
  params.oauth_verifier = verifier
  params.oauth_version = '1.0'

  var input = signatureBaseString(method, url, normalizeParameters(params))
  params.oauth_signature = sign(signer, input, secret)

  // Set Authorization header
  req.set(header, scheme + ' ' + authorizationHeaderParams(params))

  // Set other headers
  req.set('Accept', accept)
  req.set('User-Agent', agent)

  // Execute request
  return req.end(function (err, res) {
    if (err) { return done(err) }
    var response = qs.parse(res.text)

    if (res.statusCode !== 200) {
      return done(new Error("Couldn't obtain token credentials"))
    }

    done(null, response)
  })
}
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;
	}
496919
private void sendOAuthHTTPRequest(String serviceName, String accessToken, String credentialToken, Response.Listener listener) {
        RequestQueue queue = Volley.newRequestQueue(mContext);
        String url = "http://" + getServerHostname() + ":" + getServerPort() + "/_oauth/" + serviceName + "/";
        //as far as I know, Facebook is the only one that only returns a long-lived token on mobile login
        String params;
        if (accessTokenServices.contains(serviceName)) {
            params = "?accessToken=" + accessToken + "&state=" + generateState(credentialToken);
        } else {
            params = "?code=" + accessToken + "&state=" + generateState(credentialToken);
        }

        StringRequest request = new StringRequest(Request.Method.GET, url + params,
                listener, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.printStackTrace();
                if (BuildConfig.DEBUG) {
                    log.debug("If you're getting a weird error, " +
                            "this could be because you haven't configured " +
                            "your server for ddp loginWithOAuth yet. " +
                            "For Facebook login, remove accounts-facebook " +
                            "and add jasperlu:accounts-facebook-ddp instead.");
                }
            }
        });

        queue.add(request);
    }
692784
public OAuthAccessToken refreshToken(RequestContext requestContext, OAuthAccessToken token) {
    OAuthAccessToken result = token;
    
    String[] scopes = token.getScopes();
    String tokenUrl = String.format("%s/realms/%s/protocol/openid-connect/token", getServerUrl(), getRealm());
    
    HttpPost httpPost = new HttpPost(tokenUrl);
    
    try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
      List<NameValuePair> params = new ArrayList<NameValuePair>();
      params.add(new BasicNameValuePair("client_id", getApiKey()));
      params.add(new BasicNameValuePair("client_secret", getApiSecret()));
      params.add(new BasicNameValuePair("grant_type", "refresh_token"));
      params.add(new BasicNameValuePair("refresh_token", token.getRefreshToken()));

      httpPost.setEntity(new UrlEncodedFormEntity(params));
      try (CloseableHttpResponse response = httpclient.execute(httpPost)) {
        StatusLine statusLine = response.getStatusLine();
        
        if (statusLine.getStatusCode() == 200) {
          HttpEntity entity = response.getEntity();
          
          ObjectMapper objectMapper = new ObjectMapper();
          try (InputStream stream = entity.getContent()) {
            RefreshTokenResponse refreshTokenResponse = objectMapper.readValue(stream, RefreshTokenResponse.class);
            Date expiresAt = getExpiresAt(refreshTokenResponse.getExpiresIn());
            result = new OAuthAccessToken(token.getExternalId(), refreshTokenResponse.getAccessToken(), refreshTokenResponse.getRefreshToken(), expiresAt, scopes);
            AuthUtils.purgeOAuthAccessTokens(requestContext, getName());
            AuthUtils.storeOAuthAccessToken(requestContext, getName(), result);            
          }
          
          EntityUtils.consume(entity);
        } else {
          logger.log(Level.WARNING, String.format("Failed to refresh access token with message [%d]: %s", statusLine.getStatusCode(), statusLine.getReasonPhrase()));
        }
      }
    } catch (IOException e) {
      logger.log(Level.WARNING, "Failed to refresh access token", e);
    }
    
    return result;
  }
1055222
public String auth_createToken()
    throws FacebookException, IOException {
    T d = this.callMethod(FacebookMethod.AUTH_CREATE_TOKEN);
    return extractString(d);
  }
68894
private String _getAuthorizationUrl(String oauthCallback) {
		String url = null;
        
		try {
            url = mOAuthProvider.retrieveRequestToken(mOAuthConsumer, oauthCallback);
        }
        catch (OAuthException e) {
            e.printStackTrace();
        }
		
		return url;
	}
1127264
def temporary_url(expires_at = Time.now + 3600)
      url = URI.escape("#{protocol}#{host(true)}/#{path_prefix}#{key}")
      signature = Signature.generate_temporary_url_signature(:bucket => name,
                                                             :resource => key,
                                                             :expires_at => expires_at,
                                                             :secret_access_key => secret_access_key)

      "#{url}?SNDAAccessKeyId=#{access_key_id}&Expires=#{expires_at.to_i.to_s}&Signature=#{signature}"
    end
575794
public CommonProfile validateToken(final String token) {
        final TokenCredentials credentials = new TokenCredentials(token);
        try {
            validate(credentials, null);
        } catch (final HttpAction e) {
            throw new TechnicalException(e);
        } catch (final CredentialsException e) {
            logger.info("Failed to retrieve or validate credentials: {}", e.getMessage());
            logger.debug("Failed to retrieve or validate credentials", e);
            return null;
        }
        return credentials.getUserProfile();
    }
1336112
public int auth_getUserId(String authToken)
    throws FacebookException, IOException {
    /*
     * Get the session information if we don't have it; this will populate
	   * the user ID as well.
	   */
    if (null == this._sessionKey)
      auth_getSession(authToken);
    return this._userId;
  }
1270208
@Override
    public OAuth2AccessToken readAccessToken(String accessToken) {
        TokenValidation tokenValidation =
                tokenValidationService.validateToken(accessToken, true).checkJti();

        Map<String, Object> claims = tokenValidation.getClaims();
        accessToken = tokenValidation.getJwt().getEncoded();

        // Expiry is verified by check_token
        CompositeToken token = new CompositeToken(accessToken);
        token.setTokenType(OAuth2AccessToken.BEARER_TYPE);
        token.setExpiration(new Date(Long.valueOf(claims.get(EXP).toString()) * 1000L));

        @SuppressWarnings("unchecked")
        ArrayList<String> scopes = (ArrayList<String>) claims.get(SCOPE);
        if (null != scopes && scopes.size() > 0) {
            token.setScope(new HashSet<>(scopes));
        }
        String clientId = (String)claims.get(CID);
        String userId = (String)claims.get(USER_ID);
        BaseClientDetails client = (BaseClientDetails) clientDetailsService.loadClientByClientId(clientId, IdentityZoneHolder.get().getId());
        // Only check user access tokens
        if (null != userId) {
            @SuppressWarnings("unchecked")
            ArrayList<String> tokenScopes = (ArrayList<String>) claims.get(SCOPE);
            approvalService.ensureRequiredApprovals(userId, tokenScopes, (String) claims.get(GRANT_TYPE), client);
        }

        return token;
    }