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

257 views
Skip to first unread message

Mike Enos

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

Hi There,

I spent 30 minutes typing this before, but it seemed to disappear once I posted it
So I hope this isn't a duplicate.

I am trying to get v201708 working.

After getting everything setup, When  I try to run I get the failure seen below:

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 installed in my home directory of C:\Users\MXXXXXXX\
I know it is in the correct place, because if I rename it. I get the following error message:
PHP Fatal error:  Uncaught exception 'InvalidArgumentException' with message 'Config file not found as specified: 'adsapi_php.ini' or in the home directory: 'C:\Users\MXXXXXXX\adsapi_php.ini'....

Below are the contents of this file





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

; Optional. Set a friendly application name identifier.
; userAgent = "INSERT_USER_AGENT_HERE"
userAgent = "GAXXX XXXXX 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 = "BRmCO1XXXXXXXXXXXXXXXXXXXX3"

; 20170918 MJE refreshToken = "INSERT_OAUTH2_REFRESH_TOKEN_HERE"
;20170920 OLD TOKEN refresh_token = "1/LCDoeNRJw48XXXXXXXXXXXXXXXXXXXXTL0_3hO29pOUm_M"
refreshToken = "1/EKTGJOYehXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXkIn6a1BSMFjd6SJZlj7lx"




; 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 = "this is my real email addressXXXXXXXXXXXXX"

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



Note!! I did not set jsonKeyFilePath   Am I supposed to change that?

Thanks for pointing in the right direction.

..Mike
Reply all
Reply to author
Forward
0 new messages