src/Widop/GoogleAnalytics/Client.php
public function getAccessToken()
    {
        if ($this->accessToken === null) {
            $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
            $content = array(
                'grant_type'     => 'assertion',
                'assertion_type' => 'http://oauth.net/grant_type/jwt/1.0/bearer',
                'assertion'      => $this->generateJsonWebToken(),
            );

            $response = json_decode($this->httpAdapter->postContent($this->url, $headers, $content));

            if (isset($response->error)) {
                throw GoogleAnalyticsException::invalidAccessToken($response->error);
            }

            $this->accessToken = $response->access_token;
        }

        return $this->accessToken;
    }
public function getAccessToken()
    {
        if ($this->accessToken === null) {
            $headers = array('Content-Type' => 'application/x-www-form-urlencoded');
            $content = array(
                'grant_type'     => 'assertion',
                'assertion_type' => 'http://oauth.net/grant_type/jwt/1.0/bearer',
                'assertion'      => $this->generateJsonWebToken(),
            );

            $response = json_decode($this->httpAdapter->postContent($this->url, $headers, $content));

            if (isset($response->error)) {
                throw GoogleAnalyticsException::invalidAccessToken($response->error);
            }

            $this->accessToken = $response->access_token;
        }

        return $this->accessToken;
    }
public function getAccessToken ( ) { if ( $ this -> accessToken === null ) { $ headers = array ( 'Content-Type' => 'application/x-www-form-urlencoded' ) ; $ content = array ( 'grant_type' => 'assertion' , 'assertion_type' => 'http://oauth.net/grant_type/jwt/1.0/bearer' , 'assertion' => $ this -> generateJsonWebToken ( ) , ) ; $ response = json_decode ( $ this -> httpAdapter -> postContent ( $ this -> url , $ headers , $ content ) ) ; if ( isset ( $ response -> error ) ) { throw GoogleAnalyticsException :: invalidAccessToken ( $ response -> error ) ; } $ this -> accessToken = $ response -> access_token ; } return $ this -> accessToken ; }
Gets the google OAuth access token.

@throws \Widop\GoogleAnalytics\Exception\GoogleAnalyticsException If the access token can not be retrieved.

@return string The access token.
Gets the google OAuth access token .