GMB Extension FeedError.INVALID_AUTH_TOKEN_FOR_EMAIL

208 views
Skip to first unread message

Jon Perry

unread,
Apr 6, 2017, 3:24:38 PM4/6/17
to AdWords API Forum
I'm trying to set up location extensions with GMB using the code found on this page: https://developers.google.com/adwords/api/docs/samples/php/extensions

I keep getting FeedError.INVALID_AUTH_TOKEN_FOR_EMAIL. As far as I can tell I'm providing the correct email and access token.

I have a feeling I'm missing something.

Here's what I'm doing:

1. Get refresh token via OAuth2 where scope = https://www.googleapis.com/auth/plus.business.manage
2. Use refresh token to obtain an access token
3. Provide email and accound id of GMB account and access token to above function

When getting the GMB refresh token, GMB is the only scope. Do I need to include any other scopes?

Any ideas what I'm missing? 

Thanks.

Shwetha Vastrad (AdWords API Team)

unread,
Apr 6, 2017, 5:39:28 PM4/6/17
to AdWords API Forum
Hi Jon,

The scope of the OAUTH_ACCESS_TOKEN you provide in the httpAuthorizationHeader should be "https://www.googleapis.com/auth/adwords", same as the value provided in the httpRequestUrl. If you use an access token with scope "https://www.googleapis.com/auth/plus.business.manage", you'll encounter FeedError.INVALID_AUTH_TOKEN_FOR_EMAIL. Please see this guide for more information on creating the oAuthInfo object.

Regards,
Shwetha, AdWords API Team.
Message has been deleted

Enam Mino

unread,
Jan 16, 2020, 5:45:05 AM1/16/20
to AdWords API and Google Ads API Forum
Hi,
I have the same problem, but in my GET call the httpRequestUrl is https://www.googleapis.com/auth/adwords
It is exactly the url indicate in the guide

The complete error I receive is this
[FeedError.INVALID_AUTH_TOKEN_FOR_EMAIL @ operations[0].operand.systemFeedGenerationData.oAuthInfo; trigger:'x...@xxx.com']

and my code of call is this

$feedService = $this->adWordsServiceFactory->getFeedService($adWordsAccount->getAccount(), $adWordsAccount->getCustomerId());
        $gmbFeed = new Feed();
        $gmbFeed->setName('Google My Business feed #' . uniqid('', true));
        $feedData = new PlacesLocationFeedData();
        $feedData->setEmailAddress('x...@xxxxx.com');
        $oAuth2Credential = (new OAuth2TokenBuilder())
            ->withClientId($this->managerClientId)
            ->withClientSecret($this->managerClientSecret)
            ->withRefreshToken($this->managerRefreshToken)
            ->build();
        $oAuthInfo = new OAuthInfo();
        $oAuthInfo->setHttpMethod('GET');
        $oAuthInfo->setHttpRequestUrl('https://www.googleapis.com/auth/adwords');
        $oAuthInfo->setHttpAuthorizationHeader(
            sprintf('Bearer %s', $oAuth2Credential->fetchAuthToken()['access_token'])
        );
        $feedData->setOAuthInfo($oAuthInfo);
        $gmbFeed->setSystemFeedGenerationData($feedData);
        $gmbFeed->setOrigin(FeedOrigin::ADWORDS);
        $operation = new FeedOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($gmbFeed);
        $operations = [$operation];
        $addedFeed = $feedService->mutate($operations)->getValue()[0];

I used exactly the code explained in this example https://developers.google.com/adwords/api/docs/samples/php/extensions
and error is generated from mutate 
$feedService->mutate($operations)->getValue()[0];

Thanks,
Enam

Google Ads API Forum Advisor Prod

unread,
Jan 16, 2020, 10:32:57 AM1/16/20
to enam...@gmail.com, adwor...@googlegroups.com
Hi Enam,

Thank you for reaching out. Can you please provide the complete detailed request and response logs via reply privately to author so that I can further investigate the issue? You can find information on enabling logging here.

Regards,
Mitchell
Google Ads API Team

ref:_00D1U1174p._5001USwcp6:ref
Reply all
Reply to author
Forward
0 new messages