infusionsoft / infusionsoft-php

PHP client library for the Infusionsoft API.
https://developer.infusionsoft.com/
Other
130 stars 128 forks source link

Something is wrong with the tokenization process #248

Closed yamyoume closed 4 years ago

yamyoume commented 4 years ago

I'm kinda now regretting using this ill-documented SDK Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://api.infusionsoft.com/token` resulted in a `400 Bad Request` response: { "error": "invalid_request", "error_description": "Invalid redirect_uri" (truncated...) in /Users/yamantarakji/Dropbox/Web_Development/www/Projects/rashad_admin/builds/development/private/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /Users/yamantarakji/Dropbox/Web_Development/www/Projects/rashad_admin/builds/development/private/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1 /Users/yamantarakji/Dropbox/Web_Development/www/Projects/rashad_admin/builds/development/private/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response)) #2 /Users/yamantarakji/Dropbox/Web_Development/www/Projects/rashad_admin/bui in /Users/yamantarakji/Dropbox/Web_Development/www/Projects/rashad_admin/builds/development/private/vendor/infusionsoft/php-sdk/src/Infusionsoft/Http/GuzzleHttpClient.php on line 74

ajohnson6494 commented 4 years ago

It looks like you have an invalid redirect_uri. Can you provide the code you are using to set your redirect_uri?

yamyoume commented 4 years ago

public function __construct($config = array())
    {
        $this->clientId = 'OUZ******************Wi5Ld5dJ2n9';
        $this->clientSecret = 'ei0Os**********MUnO';
        $this->redirectUri = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

        if (isset($config['clientId'])) {
            $this->clientId = $config['clientId'];
        }

        if (isset($config['clientSecret'])) {
            $this->clientSecret = $config['clientSecret'];
        }

        if (isset($config['redirectUri'])) {
            $this->redirectUri = $config['redirectUri'];
        }

        if (isset($config['debug'])) {
            $this->debug = $config['debug'];
        }
    }`
I want to set them statically in the class
and after it redirects me to infusionsoft website and asks to allow this app then it redirects me to this url 
http://admin.rashad.local/api/cron/infusionsoft_sync_contacts?code=aviLoz7w&scope=full%7Ccs652.infusionsoft.com&state=

btw shouldn't that be a one time thing, because I've already done that (already allowed it to use the app and everything, and it was working ,but now just suddenly it wasn't ,
I need to run a cronjob for my integration, so I need to automate the token process 
yamyoume commented 4 years ago

Ok Sorry, my bad, It was 3am yesterday and the token expired, and my script had a bug for requesting a new token, this was the issue $_SERVER['REQUEST_URI']; I used PHP_SELF and it works now