OAuth2Client::authenticated PHP Method

authenticated() public method

public authenticated ( )
    public function authenticated()
    {
        if ($this->access_token) {
            if ($this->token_info_url && $this->refresh_token) {
                // check if this access token has expired,
                $tokeninfo = $this->tokenInfo($this->access_token);
                // if yes, access_token has expired, then ask for a new one
                if ($tokeninfo && isset($tokeninfo->error)) {
                    $response = $this->refreshToken($this->refresh_token);
                    // if wrong response
                    if (!isset($response->access_token) || !$response->access_token) {
                        throw new Exception("The Authorization Service has return an invalid response while requesting a new access token. given up!");
                    }
                    // set new access_token
                    $this->access_token = $response->access_token;
                }
            }
            return true;
        }
        return false;
    }