I changed the file adwords_api.yml file to be space separated and I am still getting invalid grant.
:authentication: :method: OAuth2 :oauth2_client_id: '657744510902.apps.googleusercontent.com' :oauth2_client_secret: '_aYopQoI-TNg2vWfXYiXADm5' :oauth2_access_type: 'offline' :oauth2_approval_prompt: 'force' :oauth2_scope: "userinfo.email userinfo.profile analytics.readonly http://gdata.youtube.com https://adwords.google.com/api/adwords/" :oauth2_callback: 'http://127.0.0.1:3000/users/auth/google_oauth2/callback' :developer_token: 'wpKZlLZDJOkLaDWrmYo8dQ' :user_agent: MARKETSTARTER :service: :environment: PRODUCTION :connection: :enable_gzip: false :library: :log_level: INFO Omniauth works fine. I am able to get the access token, refresh token, and verification code for the user. I get the user to approve all the necessary scopes as well. Screenshot attached. The problem starts when I call a method trying to access the AdWords API and authorize. That is when I get the invalid grant error. Here is the method I am using to call the AdWords API and the adwords_api.yml file setup. def update_adwords self.google_refresh_access_token unless self.google_access_token_live? #refresh access token if over an 1 hour old. google_authentication = self.authentications.find(:first, :conditions => { :provider => 'google_oauth2'}) config_filename = File.join(Rails.root, 'config', 'adwords_api.yml') adwords = AdwordsApi::Api.new(config_filename) api_version = :v201302 * token = adwords.authorize({:oauth2_verification_code => google_authentication.verification_code}) #this is where error is happening* campaign_srv = adwords.service(:CampaignService, api_version) end :authentication: :method: OAuth2 :oauth2_client_id: '657744510902.apps.googleusercontent.com' :oauth2_client_secret: '_aYopQoI-TNg2vWfXYiXADm5' :oauth2_access_type: 'offline' :oauth2_approval_prompt: 'force' :oauth2_scope: "userinfo.email userinfo.profile analytics.readonly http://gdata.youtube.com https://adwords.google.com/api/adwords/" :oauth2_callback: 'http://127.0.0.1:3000/users/auth/google_oauth2/callback' :developer_token: 'wpKZlLZDJOkLaDWrmYo8dQ' :user_agent: MARKETSTARTER :service: :environment: PRODUCTION :connection: :enable_gzip: false :library: :log_level: INFO Any additional help would be greatly appreciated. I've been stuck for 2 days now. On Friday, May 24, 2013 7:24:55 AM UTC-7, Anash P. Oommen (AdWords API Team) wrote: > > HI Christopher, > > You might want to check omniauth documentation. At for OAuth2, scope is > separated by spaces, not comma. > > Cheers, > Anash P. Oommen, > AdWords API Advisor. > > On Thursday, May 23, 2013 11:26:29 PM UTC+5:30, Christopher Sell wrote: >> >> Hi, I am using omniauth to authenticate my users with Google. When the >> user comes back I store their access_token, refresh_token, and their >> verification code off of the callback parameter. >> config.omniauth :google_oauth2, ENV['GOOGLE_CONSUMER_KEY'], >> ENV['GOOGLE_CONSUMER_SECRET'], >> { >> :scope => >> "userinfo.email,userinfo.profile,analytics.readonly, >> http://gdata.youtube.com,https://adwords.google.com/api/adwords/", >> :approval_prompt => "force", >> :access_type => "offline" >> } >> >> When I then try to make a call to the API using the google-api-ads-ruby >> gem I run into trouble. >> config_filename = File.join(Rails.root, 'config', 'adwords_api.yml') >> adwords = AdwordsApi::Api.new(config_filename) >> api_version = :v201302 >> token = adwords.authorize({:oauth2_verification_code => >> google_authentication.verification_code}) >> campaign_srv = adwords.service(:CampaignService, api_version) >> >> I get an invalid grant error on the adwords.authorize line. >> Here is my adwords_api.yml file with the id,secret, and dev token >> replaced. >> >> :authentication: >> # Authentication method, for web applications OAuth is recommended. >> :method: OAuth2 >> >> # https://code.google.com/apis/console#access >> :oauth2_client_id: MY_CLIENT_ID >> :oauth2_client_secret: MY_CLIENT_SECRET >> :oauth2_access_type: 'offline' >> :scope: 'userinfo.email,userinfo.profile,analytics.readonly, >> http://gdata.youtube.com,https://adwords.google.com/api/adwords/' >> :oauth2_callback: ' >> http://127.0.0.1:3000/users/auth/google_oauth2/callback' >> >> # Other parameters. >> :developer_token: MY_DEVELOPER_TOKEN >> :user_agent: MARKETSTARTER >> :service: >> :environment: PRODUCTION >> :connection: >> :enable_gzip: false >> :library: >> :log_level: INFO >> >> >> >> >> Does anyone know why this would cause an invalid grant error? I think I >> have everything set up properly. >> >> -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en --- You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
