exact-php-client: Cant connect to Exact

Hello,

i have an application on symfony 2.8 and want to connect to your api. The authorization success and i get the authorizationCode but when i want to get the Journals i am getting this error:

Could not connect to Exact: Client error: POST https://start.exactonline.de/api/oauth2/token resulted in a '400 Bad Request' response: Bad Request

My connect function:

public function connect() {
        $em = $this->em;
        //getting exact tokens from DB
        $clientConfig = $this->getConfig();

        $connection = new Connection();
        $connection->setRedirectUrl($this->exactCallbackUrl);
        $connection->setExactClientId($this->exactClientId);
        $connection->setExactClientSecret($this->exactClientSecret);
        $connection->setBaseUrl('https://start.exactonline.de');

        if ($clientConfig->getAuthorizationcode()) {
            $connection->setAuthorizationCode($clientConfig->getAuthorizationcode());
        } // Retrieves authorizationcode from database

        if (null !== $clientConfig->getAccesstoken()) {
            $connection->setAccessToken(unserialize($clientConfig->getAccesstoken()));
        }// Retrieves accesstoken from database

        if (null !== $clientConfig->getRefreshtoken()) {
            $connection->setRefreshToken($clientConfig->getRefreshtoken());
        }// Retrieves refreshtoken from database
        if (null !== $clientConfig->getExpiresIn()) { // Retrieves expires timestamp from database
            $connection->setTokenExpires($clientConfig->getExpiresIn());
        }
        // Make the client connect and exchange tokens
        try {
            $connection->connect();
        } catch (\Exception $e) {
            throw new Exception('Could not connect to Exact: ' . $e->getMessage());
        }
        // Save the new tokens for next connections
        $clientConfig->setAccesstoken(serialize($connection->getAccessToken()));
        $clientConfig->setRefreshtoken($connection->getRefreshToken());
        $clientConfig->setExpiresIn($connection->getTokenExpires());
        $clientConfig->setUpdateDate(new \DateTime());

        $em->persist($clientConfig);
        $em->flush();

        return $connection;
    }

An auhtorizationCode from the DB:

eTWA!IAAAAHCcr0YXhas8XRzqtKBc0xBCZGYUyNUVhcSj1jiX0W0vAQEAAAEyItD_eVi1LRgnj0O0aLN9E2L18zBYgYxZo5nBs4oG6k5aBtSjsP5sP0C-E8SEWVzlr7k_XS_xHHPe7S2Z9v285nYxHI3vhoUWM1wUeHJpCxNYLmmvhhOmZQ8TPFHT3bFr9jaTz45j88tx_tPDBcHJ3mxZt3L3VWZvWL3sBY4RBp09-AqIIgzwpGMJrdcE8CCN-LcXZBxOyc2t6cRSuVSOJZ8q9Ku7RJXjR2tPMSLWbL9qJ_IZr1rHBvXFcS0CAxHtH0xB1vaFCXBPapVsza2p86Ew2bpFas5sdDtbtMw_iOjvbw8_iVLhol-rcsKFZuqJ2hRzBk9H8YQWBC7kAp48

What i am doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

These Github issues are for issues with the code, not a support forum.

But if you do not like this project, you are always free to build your own Exact client from scratch. 😉

so i found my problem:

you can only request the access token once with an authorization code. if we dont save the access token we need a new authorization code to get a new access token.

Thx for no Help - this can be closed