Closed joethekurian closed 6 years ago
Can you provide the actual contents of your yml file (but remove the sensitive components e.g. developer token and client secret) so I can double-check that the structure is correct?
Could you also provide a complete stack trace instead of just the top level error? It looks like you're using one of our examples for testing so the easiest way to do that might be to comment out the error-handling code at the bottom of the example to allow the error to propagate all the way up.
Below given is the yml file.
---
# This is an example configuration file for the AdWords API client library.
# Please fill in the required fields, and copy it over to your home directory.
:authentication:
# Authentication method, methods currently supported:
# OAUTH2, OAUTH2_SERVICE_ACCOUNT.
:method: OAuth2
# Auth parameters for OAUTH2 method.
# Set the OAuth2 client id and secret. Register your application here to
# obtain these values:
# https://console.developers.google.com/
:oauth2_client_id: 101XXXXXXXXXXXXX.apps.googleusercontent.com
:oauth2_client_secret: ccXXXXXXXXXK
# Optional, see: https://developers.google.com/accounts/docs/OAuth2WebServer
#:oauth2_callback: INSERT_OAUTH2_CALLBACK_URL_HERE
#:oauth2_state: INSERT_OAUTH2_STATE_HERE
#:oauth2_access_type: INSERT_OAUTH2_ACCESS_TYPE_HERE
#:oauth2_prompt: INSERT_OAUTH2_PROMPT_HERE
# You can define extra scopes so that you can reuse your refresh token for
# other APIs.
:refresh_token: 1/y_XXXXXXXXXXXXXXXXXX
#:oauth2_extra_scopes: [INSERT_EXTRA_SCOPES_HERE]
# Auth parameters for OAUTH2_SERVICE_ACCOUNT method. See:
# https://developers.google.com/accounts/docs/OAuth2ServiceAccount
# You can provide path to a file with 'oauth2_keyfile' or the key itself with
# 'oauth2_key' option.
#:oauth2_keyfile: INSERT_OAUTH2_KEYFILE_HERE
# Specify the issuer only if you are using a key directly with no key file.
#:oauth2_key: INSERT_OAUTH2_KEY_HERE
#:oauth2_issuer: INSERT_OAUTH2_ISSUER_HERE
# To impersonate a user set prn to an email address.
#:oauth2_prn: INSERT_OAUTH2_PRN_HERE
# Other parameters.
:developer_token: tXJXXXXXXXX
:client_customer_id: 1XX-XXX-XXXX
:user_agent: XXXXXX
:connection:
# Enable to request all responses to be compressed.
:enable_gzip: false
# If your proxy connection requires authentication, make sure to include it in
# the URL, e.g.: http://user:password@proxy_hostname:8080
# :proxy: INSERT_PROXY_HERE
:library:
# Optional: set the log level.
:log_level: DEBUG
# Optional: uncomment to skip header / summary rows in reporting.
#:skip_report_header: true
#:skip_report_summary: true
#:skip_column_header: true
# Optional: uncomment to disable user agent showing used utilities.
#:include_utilities_in_user_agent: false
I am not sure how to take the stack trace. I'm using 'get_campaign.rb' example file to test.
Please try the following:
If that still doesn't work, you can get the stack trace by removing lines 75-95 of the get_campaigns.rb example: https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/examples/v201802/basic_operations/get_campaigns.rb#L75
This will remove the custom error handling in the example and allow the error to print directly to the console, so you can copy/paste it here. This will allow me to see at what step the authentication is failing. But please try the steps up above first. I can tell from the format of your yml file that you never actually ran this setup, which adds a couple extra fields.
Yaay.. It worked like charm :D. Thanks a lot. But still I didn't understand what I did wrong in the previous method. I followed the exact steps mentioned in API docs.
Glad it worked! Can you link to the specific docs you followed so I can take a look and see where they might be improved?
I think the problem was setup_oauth2.rb link is broken in Outh2 page. So generated refresh token using python library and updated the yml file.
Thanks! I just updated the link on that page (and some other formatting that was a bit off).
While trying to run get_campaigns.rb, I'm getting an error "Authorization credentials are not valid. Edit adwords_api.yml for OAuth2 client ID and secret and run misc/setup_oauth2.rb example to retrieve and store OAuth2 tokens". I found out that 'AdsCommon::Errors::OAuth2VerificationRequired' is raising the error.
I have the client ID , Secret and Refresh token stored in yml file. Not sure why this error is happening.
I'm using v201802