使用Ruby从Adwords API获取访问令牌?

使用Ruby从Adwords API获取访问令牌?,ruby,google-ads-api,Ruby,Google Ads Api,我正在使用以下gem,我已经做了以下工作: require 'adwords_api' class Client def initialize @adwords = AdwordsApi::Api.new({ :authentication => { :method => 'OAuth2', :oauth2_client_id => 'xxxxx', :oauth2_client_secret =>

我正在使用以下gem,我已经做了以下工作:

require 'adwords_api'

class Client
  def initialize
    @adwords = AdwordsApi::Api.new({
      :authentication => {
        :method => 'OAuth2',
        :oauth2_client_id => 'xxxxx',
        :oauth2_client_secret => 'xxxxx',
        :developer_token => 'xxxx',
        :client_customer_id => '5xxxx',
        :user_agent => 'Ruby Sample'
      },
      :service => {
        :environment => 'Production'
      }
    })
  end

  def get_service(name, version)
    return @adwords.service(name, version)
  end
end

client = Client.new
campaign_srv = client.get_service(:CampaignService, nil)
campaigns = campaign_srv.get({:fields => ['Id', 'Name', 'Status']})
但我得到一个:

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

我猜是因为我没有访问令牌。我想知道我怎样才能获得访问令牌?假设我想访问多个API(从我的客户机),并且我想将该访问令牌存储在我的数据库中。有什么办法可以这样做吗?

有一个问题与此相关:是的。我看见了。从我的观点来看,他们应该记录下来。