public function authenticateUser($code)
    {

        if (!$this->canAuthenticateUser()) {
            throw new \RuntimeException(
            	'Cannot authenticate user, dependencies are missing'
            );
        }

        if (!$this->codeIsValid($code)) {
            throw new \InvalidArgumentException('Foursquare code is invalid');
        }

        $response = json_decode($this->httpClient->get($this->accessTokenUri, array(
            'client_id' => $this->clientId,
            'client_secret' => $this->clientSecret,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $this->redirectUri,
            'code' => $code,
        )));

        $this->token = isset($response->access_token)
            ? $response->access_token : null;

        return $this->token;

    }