Configure authorization in case of api_token
usage.
4.x | 5.x |
No configuration needed, api_token should have been set when the Client instance was created. |
Default configuration should be updated by setting the api key with the use Pipedrive\Configuration;
$config = new Configuration();
$config->setApiKey('api_token', 'YOUR_API_TOKEN'); |
Configure authorization in case of OAuth 2.0 usage.
4.x | 5.x |
OAuth 2.0 configuration properties should have been set when Client instance was created.
Stored user tokens have to be set by re-assigning use Pipedrive\Configuration;
Configuration::$token = (object) [
'accessToken' => 'USER_ACCESS_TOKEN',
'refreshToken' => 'USER_REFRESH_TOKEN',
'expiry' => 'USER_ACCESS_TOKEN_EXPIRATION_MS',
'tokenType' => 'Bearer',
];
Configuration::$oAuthTokenUpdateCallback = function($token) {
// use session or some other way to persist the $token
}; |
Default configuration should be updated with OAuth 2.0 properties.
use Pipedrive\Configuration;
$config = new Configuration();
$config->setClientId('YOUR_APP_CLIENT_ID');
$config->setClientSecret('YOUR_APP_CLIENT_SECRET');
$config->setOauthRedirectUri('YOUR_APP_REDIRECT_URI');
$config->setOAuthTokenUpdateCallback(function () {
// use session or some other way to persist the $token
}); Stored user tokens have to be set with $config->updateOAuthRelatedFields([
'expires_in' => 'USER_ACCESS_TOKEN_EXPIRATION_MS',
'access_token' => 'USER_ACCESS_TOKEN',
'refresh_token' => 'USER_REFRESH_TOKEN',
'api_domain' => 'USER_API_DOMAIN',
]); |
4.x | 5.x |
Create an instance of Client and navigate the user to authorization URL:
use Pipedrive\Client;
$client = new Client(/* ... */);
$client->auth()->buildAuthorizationUrl()); Handle the incoming request, exchange use Pipedrive\Client;
$code = /* get query param value */;
$client = new Client(/* ... */);
$token = $client->auth()->authorize($code); |
Update config with your app properties.
use Pipedrive\Configuration;
$config = new Configuration();
/* ... */
$config->getAuthorizationPageUrl(); Handle incoming request, exchange use Pipedrive\Configuration;
$config = new Configuration();
/* ... */
$config->authorize($code); This will automatically set token properties (using |
Here are some examples based on the deal entity.
4.x | 5.x |
use Pipedrive\Client;
/* ...configuration needed here... */
$client = new Client(/* ... */);
$client->getDeals()->getAllDeals([
'limit' => 10,
'status' => 'open',
]); |
use Pipedrive\Client;
$config = new Configuration();
/* ...configuration needed here... */
$dealsApiInstance = new DealsApi(null, $config);
$response = $dealsApiInstance->getDeals(
null,
null,
null,
'open',
0,
10,
); |
4.x | 5.x |
use Pipedrive\Client;
/* ...configuration needed here... */
$client = new Client(/* ... */);
$response = $client->getDeals()->addADeal([
'title' => 'DEAL_TITLE'
]); |
use Pipedrive\Client;
use Pipedrive\Model\NewDeal;
$config = new Configuration();
/* ...configuration needed here... */
$dealsApiInstance = new DealsApi(null, $config);
$response = $dealsApiInstance->addDeal(new NewDeal([
'title' => 'DEAL_TITLE',
])); |
4.x | 5.x |
use Pipedrive\Client;
/* ...configuration needed here... */
$client = new Client(/* ... */);
$response = $client->getDeals()->updateADeal([
'id' => 'DEAL_ID',
'title' => 'DEAL_TITLE_UPDATED'
]); |
use Pipedrive\Client;
use Pipedrive\Model\NewDeal;
$config = new Configuration();
/* ...configuration needed here... */
$dealId = /* DEAL_ID */;
$dealsApiInstance = new DealsApi(null, $config);
$response = $dealsApiInstance->updateDeal($dealId, new UpdateDealRequest([
'title' => 'DEAL_TITLE_UPDATED',
])); |
4.x | 5.x |
use Pipedrive\Client;
/* ...configuration needed here... */
$client = new Client(/* ... */);
$response = $client->getDeals()->deleteADeal('DEAL_ID'); |
use Pipedrive\Client;
$config = new Configuration();
/* ...configuration needed here... */
$dealId = /* DEAL_ID */;
$dealsApiInstance = new DealsApi(null, $config);
$response = $dealsApiInstance->deleteDeal($dealId); |