Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* #25 - USER_PERMISSION_DENIED. The loginCustomerId header is not added #26

Merged
merged 2 commits into from
Feb 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Google/Ads/GoogleAds/Lib/GoogleAdsGapicClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
trait GoogleAdsGapicClientTrait
{
private static $DEVELOPER_TOKEN_KEY = 'developer-token';
private static $LOGIN_CUSTOMER_ID = 'login-customer-id';

private $developerToken = null;
private $loginCustomerId = null;

/**
* @see GapicClientTrait::modifyClientOptions()
Expand All @@ -38,6 +40,9 @@ protected function modifyClientOptions(array &$options)
if (isset($options[self::$DEVELOPER_TOKEN_KEY])) {
$this->developerToken = $options[self::$DEVELOPER_TOKEN_KEY];
}
if (isset($options[self::$LOGIN_CUSTOMER_ID])) {
$this->loginCustomerId = $options[self::$LOGIN_CUSTOMER_ID];
}
}

/**
Expand All @@ -46,9 +51,12 @@ protected function modifyClientOptions(array &$options)
protected function modifyUnaryCallable(callable &$callable)
{
if (!is_null($this->developerToken)) {
$callable = new FixedHeaderMiddleware($callable, [
self::$DEVELOPER_TOKEN_KEY => [$this->developerToken]
]);
$headers = [self::$DEVELOPER_TOKEN_KEY => [$this->developerToken]];

if (!is_null($this->loginCustomerId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a brace around this if clause, per PSR-2 standard?

$headers[self::$LOGIN_CUSTOMER_ID] = [$this->loginCustomerId];

$callable = new FixedHeaderMiddleware($callable, $headers);
}
$callable = new GoogleAdsExceptionMiddleware($callable);
$callable = new GoogleAdsResponseMetadataCallable($callable);
Expand Down