Giter VIP home page Giter VIP logo

google-api-ads-ruby's People

Contributors

christopherseeley avatar davidtorres avatar dklimkin avatar donovanfm avatar edmund avatar hokichaio avatar ianks avatar mcloonan avatar n1sym avatar nicholaschen avatar novito avatar rajeshkp avatar rodrigomz avatar seuros avatar tlynam avatar vankobe avatar vierarb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

google-api-ads-ruby's Issues

Adwords client extremely slow in development environment

Requests to all Adwords services takes minutes to execute locally, while no delays occured in production. Profiling didn't helped, seems it just waiting for response from adwords api server. Switching to production mode (rails env, not adwords since I have to test with real data) didn't helped. I got report from other team members about the problem, so it is not internet connection related. We're all Ukraine and Russia located, so I tried running it through AWS hosted US VPN to no avail. Crawled through docs to find limitations or thresholds - found nothing.

After several day of struggling with the problem I've finally resorted to create this ticket hoping to gather more info on topic. Is there anything I should be aware of that would cause such delays in API responce. Any API server-side logs I can check? Thanks.

OAuth Invalid Token for Offline token

I have the following situation:

First time the User gives my application permition to access its Adwords account, I store the following in my DB:

access_token, refresh_token, expires_in, issued_at

Later, when I want to do an API call, I get those values from the current user, and do the following:

@api = AdwordsApi::Api.new(config_filename) token = {:access_token => current_user.access_token, :refresh_token => current_user.refresh_token, :expires_in => current_user.adwords_expires_in, :issued_at => current_user.adwords_issued_at, :id_token => nil } credentials = @api.credential_handler() credentials.set_credential(:oauth2_token, token) credentials.set_credential(:client_customer_id, selected_account)
However, it seems that when that access_token has expired, I get a OAUTH INVALID TOKEN error.

Isn't this the correct way of doing offline access? What am I missing here? I am also guessing that if I do it this way, I would never be updating the access_token with the new access_token that I got from the refresh_token, so I am wondering what would be the correct way to do so?

PD: It would be nice if you could tell the people that manage the API Adwords forum to check for new users and accept/approval their messages ;)

proxy settings not honored for Auth

Hi. I am specifying proxy settings in the yml file correctly yet authorize is not working.
However once authorized (on another connection) I can use the api for about an hour via the proxy
I am using oauth2 and your sample script setup_oauth2

Tried to find the problem and got as far as:
/signet-0.5.0/lib/signet/oauth_2/Client.rb inside :

def fetch_access_token 

My Faraday::Connection instance has @proxy=nil

options[:connection] ||= Faraday.default_connection 

I found options[:connection] is always blank!

And here is my timeout error I get, which can help you trace the error

ruby/2.0.0/net/http.rb:878:in `initialize': A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. - connect(2) (Errno::ETIMEDOUT)

        from /ruby/2.0.0/net/http.rb:878:in `open'
        from /ruby/2.0.0/net/http.rb:878:in `block in connect'
        from /ruby/2.0.0/timeout.rb:52:in `timeout'
        from /ruby/2.0.0/net/http.rb:877:in `connect'
        from /ruby/2.0.0/net/http.rb:862:in `do_start'
        from /ruby/2.0.0/net/http.rb:851:in `start'
        from /ruby/2.0.0/net/http.rb:1367:in `request'
        from /ruby/gems/2.0.0/gems/faraday-0.9.0.rc6/lib/faraday/adapter/net_http.rb:79:in `perform_request'
        from /ruby/gems/2.0.0/gems/faraday-0.9.0.rc6/lib/faraday/adapter/net_http.rb:38:in `call'
        from /ruby/gems/2.0.0/gems/faraday-0.9.0.rc6/lib/faraday/request/url_encoded.rb:15:in `call'
        from /ruby/gems/2.0.0/gems/signet-0.5.0/lib/signet/oauth_2/client.rb:884:in `fetch_access_token'
        from /ruby/gems/2.0.0/gems/signet-0.5.0/lib/signet/oauth_2/client.rb:911:in `fetch_access_token!'
        from /ruby/gems/2.0.0/gems/signet-0.5.0/lib/signet/oauth_2/client.rb:926:in `refresh!'
        from /ruby/gems/2.0.0/gems/google-ads-common-0.9.5/lib/ads_common/auth/oauth2_handler.rb:93:in `refresh_token!'
        from /ruby/gems/2.0.0/gems/google-ads-common-0.9.5/lib/ads_common/auth/oauth2_handler.rb:83:in `get_token'
        from /ruby/gems/2.0.0/gems/google-ads-common-0.9.5/lib/ads_common/api.rb:117:in `authorize'
        from setup_oauth2 232.rb:44:in `setup_oauth2'
        from setup_oauth2 232.rb:77:in `<main>'

Thanks for your help,

Froudy

No easy way to handle AuthenticationError's

When the DFP API returns an AuthenticationError the SavonService fails to correctly send it back as an AuthenticationError. This makes it difficult to directly handle AuthenticationErrors vs any other API error.

Error:

client error: Server application error: Failed to resolve exception (nil is not a symbol),
SOAP fault: (soap:Server) [AuthenticationError.NOT_WHITELISTED_FOR_API_ACCESS @ ] at
/usr/local/rvm/gems/ruby-1.9.3-p551/gems/google-ads-common-0.9.9/lib/ads_common/savon_service.rb:113:in `handle_errors'

Support for Ruby 2.1?

As ruby 2.1 contain better GC, would there be a plan to ensure that the lib and its dependencies being upgraded to support ruby 2.1?

savon gem version

Hello,

Would it be possible to not set the version of savon, httpi, and signet in google-ads-common.gemspec, it interferes with other gems that use and keep up to date with these gem versions,

perhaps change

  s.add_dependency('savon', '~> 1.2.0')
  s.add_dependency('httpi', '~> 1.1.0')
  s.add_dependency('signet', '~> 0.6.0')

to

  s.add_dependency('savon')
  s.add_dependency('httpi')
  s.add_dependency('signet')

this works fine for me and allows me to use other Library's that us Savon 2.10.0

Thank you

OAuth2 token refresh failed

Hi,

Starting about a week ago we started receiving "OAuth2 token refresh failed" error messages. We have scheduled jobs that download data at 3:30 AM and 5:30 AM. They have both been failing with this error. If we try again at 7AM then it sometimes succeeds. Today, it did not succeed until 9:45 AM. Any idea why this has started happening? Is there something we can do to help debug the issue? We have not made any code changes for several months.

Thanks, Rohit

ERROR 2014-01-25 03:30:35 21896 [Vulcan::Google]: msg:#<AdsCommon::Errors::AuthError: OAuth2 token refresh failed>
/home/offers/tracking/shared/bundle/jruby/1.9/gems/google-ads-common-0.9.3/lib/ads_common/auth/oauth2_handler.rb:94:in `refresh_token!'
/home/offers/tracking/shared/bundle/jruby/1.9/gems/google-ads-common-0.9.3/lib/ads_common/auth/oauth2_handler.rb:83:in `get_token'
/home/offers/tracking/shared/bundle/jruby/1.9/gems/google-ads-common-0.9.3/lib/ads_common/api.rb:113:in `authorize'

Dependency on older version on Savon

v0.14.1 of google-adwords-api depends on google-ads-common (~>0.9.6). google-ads-common has a hard dependency on >1.2.0 of savon, this gem is currently at 2.8.0. Our application has other dependencies on this higher version (>2.8.0), thus we can not go ahead to use google-adwords-api.

Can we have you to release a new version with upgraded dependencies ?

API fails when requested data is more than 90 days old

I didn't see this documented anywhere but it appears that at least for the click performance report you can't request data more than 90 days old. If you do the gem will raise AdwordsApi::Errors::ReportXmlError: AdwordsApi::Errors::ReportXmlError, which is misleading.

It would be better if this limitation was documented and the error was more informative.

HTTPClient::SendTimeoutError: execution expired

We've been getting this error while updating Ad Params: HTTPClient::SendTimeoutError: execution expired. For some reason this seems to happen most often between 2am and 4am ET on Mondays and Fridays.

Is it possible to configure send_timeout to be longer? We tried adding it to the connection hash like we did with read_timeout and open_timeout when initializing the API object, but it doesn't seem to have had any effect.

connection: {
  read_timeout: 1800,
  open_timeout: 600,
  send_timeout: 600
}

Bug: Found a typo in adwords_api v's 201402 and 201309

Just noticed a typo in the below files (under these dirs adwords_api/lib/adwords_api/{v201402,v201309}):

  • ad_group_criterion_service_registry.rb
  • ad_group_service_registry.rb
  • bidding_strategy_service_registry.rb
  • campaign_service_registry.rb
  • mutate_job_service_registry.rb

In each of these files :raise_bid_when_budget_constained should be :raise_bid_when_budget_constrained (i.e. constrained is missing an r).

For example, here's the line for v201402's ad_group_service_registry.rb.

testing account has no data during retrieving.

I am using testing account (created from my google email account) from google api console and a developer token approved by google. I am able to access the adwords api, yet there is no data to retrieve with my testing account.

I am not so clear about that testing account, should I create testing account by using production MCC account or else?

How can I get data for development purpose?

Add License

Hi,

I assume, the code is still licensed as Apache 2.0, as it used to be.
Could you please add the License nonetheless to make it clear?
Thank you and keep up the good work!

Environment 'PRODUCTION' does not support version 'v201402'

I keep getting an error whenever running rails demo application to list all campaigns from my testing account.

Environment 'PRODUCTION' does not support version 'v201402'

I even changed the version to 'v201309', yet the result is the same as above.

am I making any mistake during OAuth2 process?

Setting Custom Field Value for Creative. Example seems broken

Hi, this is issue is regarding this: https://github.com/googleads/google-api-ads-ruby/blob/master/dfp_api/examples/v201505/custom_field_service/set_line_item_custom_field_value.rb

I'm following the example and setting the value of my custom field like so:

    custom_field_value = {
      :custom_field_id => custom_creative_field_id,
      :type => 'CustomFieldValue',
      :value => {:type => 'TextValue', :value => ad.current_design_version.vox_ad_name.to_s}
    }

But I keep getting this error: AdsCommon::Errors::UnexpectedParametersError: [:type, :value]
Is there a change in the keys needed for this instance?

Getting MCC Account hierarchy.rb broken/impossible for v201409 ?

The example https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/examples/v201409/account_management/get_account_hierarchy.rb is broken for me. According to the API docs: https://developers.google.com/adwords/api/docs/reference/v201409/ManagedCustomerService this requres a customer_client_id to be set. Which is weird to me, as the main goal here is to get the hierarchy for a MCC account. Setting a random has no effect, as the adwords.use_mcc() call prevents the customer_client_id header from being set at all.

Can I get my account hierarchy some other way?

Files in google-dfp-api-0.9.0.gem not world-readable

Many of the files in the google-dfp-api-0.9.0.gem file are not world-readable, which causes them to be unreadable by our app server processes, leading to errors like this:

LoadError
cannot load such file -- dfp_api/v201408/company_service

Here's a sample of the non-world-readable files in the gem:

$ curl -Lo google-dfp-api-0.9.0.gem https://github.com/googleads/google-api-ads-ruby/releases/download/dfp_api-0.9.0/google-dfp-api-0.9.0.gem
$ gem unpack google-dfp-api-0.9.0.gem
$ ls -R google-dfp-api-0.9.0/* | grep -e "-rw-r-----"
-rw-r-----  1 lovitt  staff    11K Sep 19 10:00 google-dfp-api-0.9.0/COPYING
-rw-r-----  1 lovitt  staff   3.1K Sep 19 10:00 google-dfp-api-0.9.0/ChangeLog
-rw-r-----  1 lovitt  staff   9.1K Sep 19 10:00 google-dfp-api-0.9.0/README.md
-rw-r-----  1 lovitt  staff   2.3K Sep 19 10:00 google-dfp-api-0.9.0/dfp_api.yml
-rw-r-----   1 lovitt  staff   2.6K Sep 19 10:00 dfp_api.rb
-rw-r-----   1 lovitt  staff   1.5K Sep 19 10:00 dfp_api_statement.rb
-rw-r-----   1 lovitt  staff    11K Sep 19 10:00 api_config.rb
-rw-r-----   1 lovitt  staff   1.7K Sep 19 10:00 client_login_header_handler.rb
-rw-r-----   1 lovitt  staff   2.0K Sep 19 10:00 credential_handler.rb
-rw-r-----   1 lovitt  staff   2.1K Sep 19 10:00 errors.rb
-rw-r-----   1 lovitt  staff   906B Sep 19 10:00 version.rb
-rw-r-----   1 lovitt  staff   1.0K Sep 19 10:00 audience_segment_service.rb
-rw-r-----   1 lovitt  staff   7.7K Sep 19 10:00 audience_segment_service_registry.rb
-rw-r-----   1 lovitt  staff   1.4K Sep 19 10:00 company_service.rb
-rw-r-----   1 lovitt  staff    11K Sep 19 10:00 company_service_registry.rb
-rw-r-----   1 lovitt  staff   1.2K Sep 19 10:00 content_service.rb
-rw-r-----   1 lovitt  staff   8.7K Sep 19 10:00 content_service_registry.rb
...

For anyone else having this problem, we have worked around it for now by making the following change in our application Gemfile, to pull files directly from the Git repo instead of using the pre-built gem:

-gem "google-dfp-api",           "~> 0.9.0"
+gem "google-dfp-api",           "~> 0.9.0", :github => "googleads/google-api-ads-ruby"

spider_campaigns_yesterday.rb is missing from the v201402 examples

As this is probably what a lot of people are doing - looking at the costs & clicks of their campaign for specific dates, it would be nice to get this back. I'm having real difficulties getting the stats. I understand that they have been moved to Reporting, but an example that actually fetches data instead of downloading a file would really help.

Unable to CustomerService.get without customer ID

My customer are connecting to my application by oauth authorization.

When I get refresh token and access token I was setted up Adwords::Api instance withou client_customer_id and asked CustomerService.get for authorized customer. Adwords API has in documentation:

CLIENT_CUSTOMER_ID_IS_REQUIRED
Client Customer Id is required if CustomerIdMode is set to CLIENT_EXTERNAL_CUSTOMER_ID. Starting version V201409 ClientCustomerId will be required for all requests except for CustomerService.get

so it should not be problem to do this request. But when you try to initialize instance of Adwords:API without client_customer_id you get:

AdwordsApi::Errors::BadCredentialsError: Missing client customer ID for the request.
from /Users/bartas/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/google-adwords-api-0.15.0/lib/adwords_api/credential_handler.rb:74:in `validate_headers_for_server'

Do you have any idea how to get customer id of authorized user from api by giving only access token?

Bes Ondrej

Problem in getting the refresh token with the recent version

Hi There,

We noticed that recently we couldn't get a refresh token for our web application using this gem. We have been using this gem continuously for 3 years without issue with getting refresh token.

We have added the param in our code such as ;
api.authorize({ oauth2_callback: oauth2_callback_platform_partners_url,
oauth2_access_type: "offline", # ask to return refresh token
approval_prompt: "force" }) # force to request user consent

It works in 'localhost', but not in other domain than "localhost" such as our production app. We only being returned the access token without refresh token. And no user consent window had pop up on our production app.

Any changes in they way the gem handles OAuth2?

:ManagedCustomerService gives [AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED]

Hi,
Yestarday i updated google-adwords-api to 0.13.2, i am using v201409 version of API.
Everything works ok, i can download reports, campaigns, budgets etc.
But i cannot get sub accounts from our mcc client using :ManagedCustomerService, i am getting AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED.
This is somehow connected to "clientCustomerId is now a required header for all services except CustomerService." change in v201409.

This is the code i am using:

Auhorise part (cleaned up):

api = AdwordsApi::Api.new(path_to_yml_config)
api.authorize({:oauth2_token => load_session_token})
credentials = api.credential_handler()
credentials.set_credential(:oauth2_token, load_session_token)
credentials.set_credential(:client_customer_id, load_master_mcc_account)

Getting sub-accounts:

service = api.service(:ManagedCustomerService,  "v201409")
selector = {:fields => ['Login', 'CustomerId', 'CompanyName', 'Name','DateTimeZone', 'CurrencyCode']}
result = adwords.use_mcc {service.get(selector)}

The last line service.get(selector) throw exception AuthenticationError.CLIENT_CUSTOMER_ID_IS_REQUIRED

Migration guide says clientCustomerId is now a required header, but i dont see how i can set this from outside google-api gem.

Any help would be greatly appreciated,
Thank you.

Conflict with Google API Client

My app is currently using

google-api-client

and it is conflicting when I try to install google-adwords-api

here is what I get.

Bundler could not find compatible versions for gem "signet":
In Gemfile:
google-adwords-api (>= 0) x86-mingw32 depends on
google-ads-common (> 0.9.0) x86-mingw32 depends on
signet (
> 0.4.4) x86-mingw32

google-api-client (>= 0) x86-mingw32 depends on
  signet (0.6.0)

Bundler could not find compatible versions for gem "savon":
In Gemfile:
google-adwords-api (>= 0) x86-mingw32 depends on
google-ads-common (> 0.2.0) x86-mingw32 depends on
savon (
> 0.9.1) x86-mingw32

savon (2.9.0)

Bundler could not find compatible versions for gem "httpi":
In Gemfile:
google-adwords-api (>= 0) x86-mingw32 depends on
google-ads-common (> 0.2.0) x86-mingw32 depends on
httpi (
> 0.7.9) x86-mingw32

httpi (2.3.0)

So is it impossible to use google-adwords-api and google-api-client? And also savon 2.9.0 and httpi 2.3.0 ?

Thanks!

Example for Setting Values of Custom Field appears to be broken

Hi, this is issue is regarding this: https://github.com/googleads/google-api-ads-ruby/blob/master/dfp_api/examples/v201505/custom_field_service/set_line_item_custom_field_value.rb

I'm following the example and setting the value of my custom field like so:

    custom_field_value = {
      :custom_field_id => custom_creative_field_id,
      :type => 'CustomFieldValue',
      :value => {:type => 'TextValue', :value => ad.current_design_version.vox_ad_name.to_s}
    }

YAML Boolean Values

Just updated to the latest version (google-adwords-api (0.15.2)) to get support for AdWords v201506 and now I'm getting the following error when using download_report_as_file

API_VERSION = :v201506
adwords_api  = AdwordsApi::Api.new(CONFIG_FILE)
report_utils = adwords_api.report_utils(API_VERSION)
report_definition = {:selector=>{:fields=>["CampaignId", "AccountCurrencyCode", "CampaignName"], :date_range=>{:min=>"20150701", :max=>"20150701"}}, :report_name=>"CAMPAIGN_PERFORMANCE_REPORT", :report_type=>"CAMPAIGN_PERFORMANCE_REPORT", :download_format=>"CSV", :date_range_type=>"CUSTOM_DATE", :include_zero_impressions=>"true"}
report_utils.download_report_as_file(report_definition, file_name, account_cid)

NoMethodError: undefined method `strip' for true:TrueClass
  from /usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http/header.rb:17:in `block in initialize_http_header'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/rack-1.6.4/lib/rack/utils.rb:490:in `block in each'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/rack-1.6.4/lib/rack/utils.rb:489:in `each'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/rack-1.6.4/lib/rack/utils.rb:489:in `each'
  from /usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http/header.rb:15:in `initialize_http_header'
  from /usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http/generic_request.rb:43:in `initialize'
  from /usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http/request.rb:14:in `initialize'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi/adapter/net_http.rb:102:in `new'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi/adapter/net_http.rb:102:in `request_client'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi/adapter/net_http.rb:76:in `block in do_request'
  from /usr/local/var/rbenv/versions/2.2.2/lib/ruby/2.2.0/net/http.rb:853:in `start'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi/adapter/net_http.rb:75:in `do_request'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi/adapter/net_http.rb:30:in `post'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi.rb:96:in `block in post'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi.rb:193:in `with_adapter'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/httpi-1.1.1/lib/httpi.rb:94:in `post'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/google-ads-common-0.9.9/lib/ads_common/http.rb:52:in `post_response'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/google-adwords-api-0.15.2/lib/adwords_api/report_utils.rb:155:in `make_adhoc_request'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/google-adwords-api-0.15.2/lib/adwords_api/report_utils.rb:139:in `get_report_response'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/google-adwords-api-0.15.2/lib/adwords_api/report_utils.rb:57:in `download_report'
  from /usr/local/var/rbenv/versions/2.2.2/gemsets/xxx/gems/google-adwords-api-0.15.2/lib/adwords_api/report_utils.rb:76:in `download_report_as_file'

It seems to be tripping up with my CONFIG_FILE on "skip_report_header".

....truncated
:library:
  :log_level: INFO
  :skip_report_header: true
  :skip_report_summary: true
  :skip_column_header: false

Changing to strings fixed the issue for me.

:library:
  :log_level: INFO
  :skip_report_header: 'true'
  :skip_report_summary: 'true'
  :skip_column_header: 'false'

I raise this here as this is breaking behaviour from the previous version.

Regards,

Lewis

How to have access tokens automatically refresh when exipred

I've done some searching but am not yet able to figure this out. The problem is I am getting a undefined method []' for nil:NilClass` error from

google-ads-common (0.9.9) lib/ads_common/auth/oauth2_jwt_handler.rb:74:in `auth_string'
google-ads-common (0.9.9) lib/ads_common/savon_headers/oauth_header_handler.rb:45:in `generate_headers'
google-ads-common (0.9.9) lib/ads_common/savon_headers/base_header_handler.rb:75:in `prepare_request'

The error is occurring because my token hash doesn't include a refresh_token. I'm authenticating using OAuth2 JWT (Service Account using a keyfile). I've set :oauth2_access_type: offline in my config file (I'm using the google-dfp-api-0.9.5 gem to access DFP) but that's not helping.

Can I get a refresh token using a service account auth method? How should I handle the case that my token has expired? I don't think it's a good idea for me to get a new token for each request, because I understand there are some limits to how many tokens I can get. I'm surprised the code doesn't just request a new access token for me when this one expires.

Here's an example of my access token:

{:access_token=>"ya29.nAHZWtk7qnaxGsXbaRHwkQdApPJWw5b0jqxtLZhkJS0xWIy0PvNCPQA3eNMW7sZ-ajZVeDpYDBKgdw", :issued_at=>2015-06-23 19:00:39 -0700, :expires_in=>3600, :id_token=>nil}

Please advise. Thanks!

Faraday::SSLError

Hi!
I'm getting a Farady issue: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed.
There is an option for disable ssl verification?

Any help will be appreciated

Get new access token sometime before expiry

Hi,

I recently attended the Adwords API workshop in Hamburg, there it was mentioned that it is ok to get a new access token before it expires (lets say 45 mins after it is issued).

However if you look at the code for OAuth2 handler for the ruby client (oauth2_handler.rb) -

  def get_token(credentials = nil)
    token = super(credentials)
    token = refresh_token! if [email protected]? && @client.expired?
    return token
  end

  # Refreshes access token from refresh token.
  def refresh_token!()
    return nil if @token.nil? or @token[:refresh_token].nil?
    begin
      @client.refresh!
    rescue Signet::AuthorizationError => e
      raise AdsCommon::Errors::AuthError.new("OAuth2 token refresh failed",
          e, (e.response.nil?) ? nil : e.response.body)
    end
    @token = token_from_client(@client)
    return @token
  end

The code says that the token can be refreshed only after it is expired. See line 2 of get_token method.

Just wanted to check if this is intentional or a bug. For us it is important as we have built an OAuth2 service for all our client apps (like you recommended) and we want to send them fresh tokens not ones which are about to expire in 15 secs for example.

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

no implicit conversion of Fixnum into String

Hi.
I'm using Rails 4, & ruby 2.1 and I'm getting this error in SOAP connection:
no implicit conversion of Fixnum into String

More details:
rails (4.1.0)
faraday (0.9.1)

google-ads-common (0.9.8)
  httpi (~> 1.1.0)
  savon (~> 1.2.0)
  signet (~> 0.6.0)
google-adwords-api (0.14.2)
  google-ads-common (~> 0.9.8)
google-dfp-api (0.9.4)
  google-ads-common (~> 0.9.4)

any suggestion?
thanks

AdSchedule specific criteria not available while fetching campaign criterions

srv = adwords.service(:CampaignCriterionService, "v201206")

selector = {
  :fields => ['Id', 'CampaignId'],
  :predicates =>
    [{
      :field => 'CampaignId',
      :operator => 'IN',
      :values => [your-campaign-id]
    }]
 }

 srv.get(selector)[:entries]

What steps will reproduce the problem?

  1. We are unable to fetch AdSchedule specific criterion using the above call in 0.7.0 (the latest version). The equivalent java call does seem to fetch AdSchedule criterion for the same campaign id.

When will this be supported?

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?
0.7.0 version of google-api-ads

Please provide any additional information below.

Use to analyze keyword viability?

Can this library be used to analyze keyword viability? I am a content producer and would like to analyze inbound content that is being posted so that I can feed Google appropriately tagged content with a better understanding of the value of inbound keywords for the content that is being produced. Can this library be used to determine rank of keywords or is there another preferred way of determining keyword value programmatically?

Message: [AuthenticationError.OAUTH_TOKEN_HEADER_INVALID @ ; trigger:'<null>'] when using refresh token

Using the example from :
https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/examples/v201409/misc/create_ad_words_session_without_properties_file.rb

I've got the following error:

Message: [AuthenticationError.OAUTH_TOKEN_HEADER_INVALID @ ; trigger:'<null>']
Errors:
    Error [1]:
        field_path:
        trigger: <null>
        error_string: AuthenticationError.OAUTH_TOKEN_HEADER_INVALID
        api_error_type: AuthenticationError
        reason: OAUTH_TOKEN_HEADER_INVALID
        xsi_type: ns2:AuthenticationError

However, if I'm authenticate by web and renew the access token by hand, saved to file, everything just going fine.

Can you guy trouble shoot the error.

Thank you very much.


Add:

After a while digging the code, I think the reason is that in the sample code:

  adwords = AdwordsApi::Api.new({
    :authentication => {
      :method => 'OAuth2',
      :oauth2_client_id => client_id,
      :oauth2_client_secret => client_secret,
      :developer_token => developer_token,
      :client_customer_id => client_customer_id
      :user_agent => user_agent,
      :oauth2_token => {
        :refresh_token => refresh_token
      }
    },
    :service => {
      :environment => 'PRODUCTION'
    }
  })

by setting oauth2_token => {:refresh_token => refresh_token},
it make developer think that implicit setting like this, will make the library to get access token by using refresh token.

But follow the code in ads-common :

      def get_token(credentials = nil)
        token = super(credentials)
        token = refresh_token! if !@client.nil? && @client.expired?
        return token
      end

it only using refresh token when @client nil or expired, and not check the credential.

I think the correct behaviour should be: [when refresh token present and access token not, it use refresh token to refresh access token.]

What do you maintainers think about this situation.

If it's fine, i would like to make a pull request

README for example rails app is all wrong

I'm not a huge Rails expert but the setup instructions seem to be all wrong. Some examples:

  • bundle install won't work because there's no Gemfile.
  • rake db:migrate won't work either.
  • Neither will script/server to start the server. I believe that would only work on a very old version of Rails and you appear to be using a newer one.

It would also be helpful to give a link to an explanation for the arduous process of obtaining a developer token.

AdsCommon::Errors::OAuth2VerificationRequired

If you follow the Readme explicitly, an error like this will raise when trying to do a simple API call:

generate_access_token': AdsCommon::Errors::OAuth2VerificationRequired (AdsCommon::Errors::OAuth2VerificationRequired)

I believe it should be explained how to grant access to the User in the Readme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.