v201708 Uncaught exception 'InvalidArgumentException' with message 'All of 'clientId', 'clientSecret', and 'refreshToken' must be set when using installed/web application flow.'

172 views
Skip to first unread message

Mike Enos

unread,
Sep 21, 2017, 1:26:20 AM9/21/17
to AdWords API Forum
Hi,

I'm trying to get v201708 working and when I try to run GetCampaigns.php I get the error message:

PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'All of 'clientId', 'clientSecret', and 'refreshToken' must be set when using installed/web application flow.' in C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php:204

Here is some info:

I am running XAmpp on Windows 10

I went through the process to get the refreshtoken. That went fine ALTHOUGH... it did give me a different one than I have been using in the older version that gets retired on October 2nd.

I am currently located  in:C:\DataH\xampp\htdocs\DBGoogleAdwords\examples\AdWords\v201708\BasicOperations>

When I type:php GetCampaigns.php

Here is the screen capture:

C:\DataH\xampp\htdocs\DBGoogleAdwords\examples\AdWords\v201708\BasicOperations>php GetCampaigns.php
PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'All of 'clientId', 'clientSecret', and 'refreshToken' must be set when using installed/web application flow.' in C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php:204
Stack trace:
#0 C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php(158): Google\AdsApi\Common\OAuth2TokenBuilder->validate()
#1 C:\DataH\xampp\htdocs\DBGoogleAdwords\examples\AdWords\v201708\BasicOperations\GetCampaigns.php(77): Google\AdsApi\Common\OAuth2TokenBuilder->build()
#2 C:\DataH\xampp\htdocs\DBGoogleAdwords\examples\AdWords\v201708\BasicOperations\GetCampaigns.php(89): Google\AdsApi\Examples\AdWords\v201708\BasicOperations\GetCampaigns::main()
#3 {main}
  thrown in C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php on line 204

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'All of 'clientId', 'clientSecret', and 'refreshToken' must be set when using installed/web application flow.' in C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php:204
Stack trace:
#0 C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php(158): Google\AdsApi\Common\OAuth2TokenBuilder->validate()
#1 C:\DataH\xampp\htdocs\DBGoogleAdwords\examples\AdWords\v201708\BasicOperations\GetCampaigns.php(77): Google\AdsApi\Common\OAuth2TokenBuilder->build()
#2 C:\DataH\xampp\htdocs\DBGoogleAdwords\examples\AdWords\v201708\BasicOperations\GetCampaigns.php(89): Google\AdsApi\Examples\AdWords\v201708\BasicOperations\GetCampaigns::main()
#3 {main}
  thrown in C:\DataH\xampp\htdocs\DBGoogleAdwords\vendor\googleads\googleads-php-lib\src\Google\AdsApi\Common\OAuth2TokenBuilder.php on line 204



My adsapi_php.ini is located in c:\Users\MYNAME\ads_php.ini.  (I know this is the correct home path because if I rename the file 
 Uncaught exception 'InvalidArgumentException' with message 'Config file not found as specified: 'adsapi_php.ini' or in the home directory: 'C:\Users\MYNAME\adsapi_php.ini'.'


I DID NOT set jsonKeyFilePath in adsapi_php.ini shown below.


Can someone please give me some help?? I've lost a day on this so far!!

Thanks,

..Mike



Below are the contents of the C:\Users\MYNAME\adsapi_php.ini file


[ADWORDS]
; Required AdWords API properties. Details can be found at:
;MJE 20170918 developerToken = "INSERT_DEVELOPER_TOKEN_HERE"
developerToken = "LHg9XXXXXXXXXXXXXXXxJA"
;MJE 20170918 clientCustomerId = "INSERT_CLIENT_CUSTOMER_ID_HERE"
clientCustomerId = "1XX-XXX-XXXX"

; Optional. Set a friendly application name identifier.
; userAgent = "INSERT_USER_AGENT_HERE"
userAgent = "GAXXX Other Client"

; 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.
;20170918 MJE  clientId = "INSERT_OAUTH2_CLIENT_ID_HERE"

; 20170918 MJE clientSecret = "INSERT_OAUTH2_CLIENT_SECRET_HERE"
client_secret = "BRmXXXXXXXXXXXXXXXXXXXX3"

; 20170918 MJE refreshToken = "INSERT_OAUTH2_REFRESH_TOKEN_HERE"
;20170920 OLD TOKEN refresh_token = "1/LCDoeNRJw48SrIrj4gNPcPjb9r3jTL0_3hO29pOUm_M"
refreshToken = "1/EKTGXXXXXXXXXXXXXXXXXXXXXXXXX4RsHZY3KkIn6a1BSMFjd6SJZlj7lx"




; For service account flow.
; jsonKeyFilePath = "INSERT_ABSOLUTE_PATH_TO_OAUTH2_JSON_KEY_FILE_HERE"
; 20170918 MJE  impersonatedEmail = "INSERT_EMAIL_OF_ACCOUNT_TO_IMPERSONATE_HERE"
impersonatedEmail = "myrea...@gmail.com"

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

[PROXY]
; Optional proxy settings to be used by SOAP requests.
; host = "<HOST>"
; port = <PORT>
; user = "<USER>"
; password = "<PASSWORD>"

[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"

Peter Oliquino

unread,
Sep 21, 2017, 3:38:52 AM9/21/17
to AdWords API Forum
Hi Mike,

I could see that you have already specified the OAuth2 credentials correctly in their respective properties in your adsapi_php.ini. However, could you confirm if you have also followed this guide when setting up your PHP client library? Also if you are using the installed app/web application flow, you may comment out all properties related to service accounts to prevent confusion.

If the issue persists, and since this is more specific to the PHP client library rather than the AdWords API itself, I would recommend that you get in touch with the PHP library owners via this link for further assistance.

Best regards,
Peter
AdWords API Team

Mike Enos

unread,
Sep 22, 2017, 8:59:45 AM9/22/17
to AdWords API Forum
Hi Peter,

When I try following this guide  I do not get the composer.phar file mentioned in step 3

In Step 1, where they say to run git clone.... they don't say which directory. I did it from c:\DataH\xampp  

Why don't I get the composer.phar file?

Here is a screenshot: 

Thanks,

..Mike

Peter Oliquino

unread,
Sep 24, 2017, 10:55:02 PM9/24/17
to AdWords API Forum
Hi Mike,

Since the issue is more related to the setup of your PHP client library, you may contact the library owners via this link for further assistance.

Mike Enos

unread,
Sep 25, 2017, 11:58:12 AM9/25/17
to AdWords API Forum
Hi,

For anyone who is reading this thread... I solved the problem.

The issue is that I am using Windows XAMPP as my development platform.

The instructions at https://github.com/googleads/googleads-php-lib  are a bit confusing /wrong for Windows Xampp

You need to go install Composer, and a git client too.

1)  It says to copy and configure adsapi_php to your "Home Directory". You might think this is your /public_html folder
On Windows this folder is C:\Users\YOURNAME  NOT your base  xampp/htdocs folder

2) Instructions say to type : php composer.phar require googleads/googleads-php-lib
Instead, you need to you need to CD to the directory where the C:\xampp\googleads-php-lib was created.
and then type:  composer install 

3) If you are upgrading from an older library, older versions of the .ini  configuration file used SLIGHTLY different variable names 
The older variables: client_id, client_secret
The newer are clientId,clientSecret
So you should copy over the values, but be careful of the variable name

This messed me up for a couple of days.

Hope that helps you out.
Reply all
Reply to author
Forward
0 new messages