You are here

public function OAuthStorePostgreSQL::setConsumerAccessTokenTtl in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.2 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::setConsumerAccessTokenTtl()
  2. 7.3 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::setConsumerAccessTokenTtl()
  3. 7.4 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::setConsumerAccessTokenTtl()
  4. 7.5 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::setConsumerAccessTokenTtl()
  5. 7.6 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::setConsumerAccessTokenTtl()

Set the ttl of a consumer access token. This is done when the server receives a valid request with a xoauth_token_ttl parameter in it.

Parameters

string token:

int ttl:

Overrides OAuthStoreAbstract::setConsumerAccessTokenTtl

File

lib/oauth-php/library/store/OAuthStorePostgreSQL.php, line 1484

Class

OAuthStorePostgreSQL

Code

public function setConsumerAccessTokenTtl($token, $token_ttl) {
  if ($token_ttl <= 0) {

    // Immediate delete when the token is past its ttl
    $this
      ->deleteConsumerAccessToken($token, 0, true);
  }
  else {

    // Set maximum time to live for this token
    $this
      ->query('
                        UPDATE oauth_server_token
                        SET ost_token_ttl = (NOW() + INTERVAL \'%d SECOND\')
                        WHERE ost_token      = \'%s\'
                          AND ost_token_type = \'access\'
                        ', $token_ttl, $token);
  }
}