Hello guys! I was building integration to my backend using PHP, I did everything by this guide, but when I try to make a request to API I get Authorization Exception. I used oAuth, I even got access token, I tried hard code this token to my code, but get Authorization Exception.
Here I’ll show my simplified version of code:
use Pipedrive\Client;
use Pipedrive\Configuration;
class PipedriveAuthService
{
public function addDeal()
{
Configuration::$oAuthToken = '333333333333333333333333333333333333333333333333';
$client = new Client(config('pipedrive.client_id'), config('pipedrive.client_secret'), url('/') . '/auth/pipedrive/callback');
$client->getDeals()->addADeal(['title' => 'awesome deal']);
}
}
If someone could help, it would be nice, thank you for your time.
I assume you have an OAuth callback handler similar to GitHub - pipedrive/client-php: Pipedrive API client for PHP. In that case, the access token will usually be set as part of the session variables (along with refresh token, scopes, and other details) & the token updation is taken care of by oAuthTokenUpdateCallback.
Thanks for sharing the code snippet. I suspect if the value for oAuthToken is properly assigned.
I guess what you have been attempting to do is to set the value of Configuration::$oAuthToken->accessToken ? I would recommend obtaining the access token via the OAuth callback handler as it is much cleaner and takes care of refreshes automatically.
Feel free to share the details of the error that you are facing
Hey hem! Thanks for your response! Actually I got through this issue by making request for deal creation using Guzzle Http Client. Now I encounter new problem, I’ve finished working with pipedrive in sandbox mode, everything I needed is now done, but I can’t find a way to switch from sandbox mode to production. In my sandbox account I can see client_id & client_secret, in my production account there is no such thing, so it probably as it should be by design, but what do I do to start using my app with production environment account? Google didn’t tell me. Thanks again!