src/Auth/Authentication.php
public function getToken( $service ) {
        if ( $this->isTokenLoaded( $service ) && !$this->isTokenExpired( $service ) ) {
            return $this->tokens[$service];
        }

        $tokenCacheKey = $this->getTokenCacheKey( $service );

        $cachedToken = $this->client->cache->get( $tokenCacheKey );
        if ( $cachedToken instanceof SecurityToken && !$cachedToken->hasExpired() ) {
            $this->tokens[$service] = $cachedToken; // save in memory

            return $cachedToken;
        }

        $this->tokens[$service] = $newToken = $this->retrieveToken( $service );
        $this->client->cache->set( $tokenCacheKey, $newToken, floor( $newToken->expiryTime - time() - 60 ) );

        return $newToken;
    }
public function getToken( $service ) {
        if ( $this->isTokenLoaded( $service ) && !$this->isTokenExpired( $service ) ) {
            return $this->tokens[$service];
        }

        $tokenCacheKey = $this->getTokenCacheKey( $service );

        $cachedToken = $this->client->cache->get( $tokenCacheKey );
        if ( $cachedToken instanceof SecurityToken && !$cachedToken->hasExpired() ) {
            $this->tokens[$service] = $cachedToken; // save in memory

            return $cachedToken;
        }

        $this->tokens[$service] = $newToken = $this->retrieveToken( $service );
        $this->client->cache->set( $tokenCacheKey, $newToken, floor( $newToken->expiryTime - time() - 60 ) );

        return $newToken;
    }
public function getToken ( $ service ) { if ( $ this -> isTokenLoaded ( $ service ) && ! $ this -> isTokenExpired ( $ service ) ) { return $ this -> tokens [ $ service ] ; } $ tokenCacheKey = $ this -> getTokenCacheKey ( $ service ) ; $ cachedToken = $ this -> client -> cache -> get ( $ tokenCacheKey ) ; if ( $ cachedToken instanceof SecurityToken && ! $ cachedToken -> hasExpired ( ) ) { $ this -> tokens [ $ service ] = $ cachedToken ; // save in memory return $ cachedToken ; } $ this -> tokens [ $ service ] = $ newToken = $ this -> retrieveToken ( $ service ) ; $ this -> client -> cache -> set ( $ tokenCacheKey , $ newToken , floor ( $ newToken -> expiryTime - time ( ) - 60 ) ) ; return $ newToken ; }
Retrieves a security token for the specified service.

@param string $service   Can be 'organization', 'discovery'

@return SecurityToken
Retrieves a security token for the specified service .