Setting up Google AdWords API (Php SDK)

376 views
Skip to first unread message

Lucy Bowe

unread,
Apr 11, 2018, 5:44:09 AM4/11/18
to AdWords API Forum
Hello,

I am following the instructions from the Google AdWords API webpage about getting everything setup. When I try to fun the example GetCampaigns.php, i get the following error:

root@business:/adwords-examples-34.0.0/adwords-examples-34.0.0# php examples/AdWords/v201710/BasicOperations/GetCampaigns.php
PHP Fatal error:  Uncaught InvalidArgumentException: All of 'clientId', 'clientSecret', and 'refreshToken' must be set when using installed/web application flow. in /root/vendor/googleads/g:225
Stack trace:
#0 /root/vendor/googleads/googleads-php-lib/src/Google/AdsApi/Common/OAuth2TokenBuilder.php(173): Google\AdsApi\Common\OAuth2TokenBuilder->validate()
#1 /adwords-examples-34.0.0/adwords-examples-34.0.0/examples/AdWords/v201710/BasicOperations/GetCampaigns.php(81): Google\AdsApi\Common\OAuth2TokenBuilder->build()
#2 /adwords-examples-34.0.0/adwords-examples-34.0.0/examples/AdWords/v201710/BasicOperations/GetCampaigns.php(90): Google\AdsApi\Examples\AdWords\v201710\BasicOperations\GetCampaigns::main(
#3 {main}

Here is the text in my adsapi_php.ini file:
[ADWORDS]
; Required AdWords API properties. Details can be found at:
developerToken = "................................."
clientCustomerId = "................................"

; Optional. Set a friendly application name identifier.
userAgent = "........................."

; Optional additional AdWords API settings.
; isPartialFailure = false

; Optional setting for utility usage tracking in the user agent in requests.
; Defaults to true.
; includeUtilitiesInUserAgent = true

[ADWORDS_REPORTING]
; Optional reporting settings.
; isSkipReportHeader = false
; isSkipColumnHeader = false
; isSkipReportSummary = false
; isUseRawEnumValues = false

[OAUTH2]
; Required OAuth2 credentials. Uncomment and fill in the values for the
; appropriate flow based on your use case. See the README for guidance:

; For installed application or web application flow.
clientId = "29..................................m"
clientSecret = "K7........................18"
refreshToken = "1/w8...............V4"


; For service account flow.
; jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE"
; impersonatedEmail = "INSERT_EMAIL_OF_ACCOUNT_TO_IMPERSONATE_HERE"

[SOAP]
; Optional SOAP settings. See SoapSettingsBuilder.php for more information.
; compressionLevel = <COMPRESSION_LEVEL>

[CONNECTION]
; Optional proxy settings to be used by requests.
; If you don't have username and password, just specify host and port.
; proxy = "protocol://user:pass@host:port"
; Enable transparent HTTP gzip compression for all reporting requests.
; enableReportingGzip = false

[LOGGING]
; Optional logging settings.
; soapLogFilePath = "path/to/your/soap.log"
; soapLogLevel = "INFO"
; reportDownloaderLogFilePath = "path/to/your/report-downloader.log"
; reportDownloaderLogLevel = "INFO"
; batchJobsUtilLogFilePath = "path/to/your/bjutil.log"
; batchJobsUtilLogLevel = "INFO"

Milind Sankeshware (AdWords API Team)

unread,
Apr 11, 2018, 2:09:38 PM4/11/18
to AdWords API Forum
Hi,

Could you please confirm have you created OAuth credentials (Client ID, Client secret)? If no, please refer this guide to create the OAuth credentials and refresh token. Please add created credentials in adsapi_php.ini file and run GetCampaigns.php. Let me know if you are still facing an issue.

Thanks,
Milind, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages