Ruby Google Adwords Api OAuth验证失败

时间:2012-03-21 04:31:29

标签: oauth google-adwords

我一直在遇到这个糟糕的OAuth验证失败,似乎不想给我一个身份验证令牌??

这是我的app.rb:

require 'adwords_api'
require 'adwords_api/utils'

adwords = AdwordsApi::Api.new
campaign_srv = adwords.service(:CampaignService, :v201109)
campaign_srv.get

这是我的adwords_api.yml:

:authentication:
 :method: OAuth
 :oauth_consumer_key: anonymous
 :oauth_consumer_secret: anonymous
 :developer_token: email@gmail.com++USD
 :user_agent: Ruby Testing
:service:
  :environment: SANDBOX
:connection:
  :enable_gzip: false
  :library:
  :log_level: INFO

每次运行应用程序时都会收到此错误:

/Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/auth/oauth_handler.rb:271:in `raise_oauth_verification_error': AdsCommon::Errors::OAuthVerificationRequired (AdsCommon::Errors::OAuthVerificationRequired)
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/auth/oauth_handler.rb:237:in `generate_access_token'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/auth/oauth_handler.rb:181:in `create_token'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/auth/base_handler.rb:62:in `get_token'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/auth/oauth_handler.rb:92:in `headers'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_headers/oauth_header_handler.rb:59:in `generate_headers'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_headers/oauth_header_handler.rb:42:in `prepare_request'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_service.rb:106:in `block in set_headers'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_service.rb:105:in `each'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_service.rb:105:in `set_headers'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_service.rb:98:in `block in execute_soap_request'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/savon-0.9.9/lib/savon/client.rb:153:in `yield_objects'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/savon-0.9.9/lib/savon/client.rb:147:in `process'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/savon-0.9.9/lib/savon/client.rb:76:in `request'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_service.rb:97:in `execute_soap_request'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-ads-common-0.6.3/lib/ads_common/savon_service.rb:80:in `execute_action'
from /Users/Qubit/.rvm/gems/ruby-1.9.2-p290/gems/google-adwords-api-0.5.2/lib/adwords_api/v201109/campaign_service.rb:19:in `get'
from app.rb:12:in `<main>'

发生了什么事?对于adwords sandbox api来说,这还不够吗?

谢谢。

1 个答案:

答案 0 :(得分:1)

我仍然不确定OAuth的问题是什么,但我发现如何在沙箱中使用'ClientLogin',这很好用。所需的只是将我的adwords_api.yml配置为

:authentication:
 :method: ClientLogin
 :password: PASSWORD_GOES_HERE
 :email: EMAIL_GOES_HERE
 :developer_token: email@gmail.com++USD
 :user_agent: Ruby Testing
:service:
  :environment: SANDBOX
:connection:
  :enable_gzip: false
  :library:
  :log_level: INFO