Giter VIP home page Giter VIP logo

Comments (10)

jstoks avatar jstoks commented on May 15, 2024 1

I worked around this by providing an expires_at value in my config.

The problem is that if the OAuth2 client doesn't have that value it's never going to be considered expired and the access token won't be generated.

from google-api-ads-ruby.

huydx avatar huydx commented on May 15, 2024

@dklimkin are you still working on issue #27 to add a library method to enforce the refresh. If not, i would like to make a pull request if it's possible.

from google-api-ads-ruby.

dklimkin avatar dklimkin commented on May 15, 2024

@mcloonan is currently maintaining the library. You are very welcome to send a pull request, please see:

https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/CONTRIBUTING.md

from google-api-ads-ruby.

huydx avatar huydx commented on May 15, 2024

@dklimkin @mcloonan thank you, I will send a PR ASAP.

from google-api-ads-ruby.

kobakei avatar kobakei commented on May 15, 2024

I found the same error on running https://github.com/googleads/google-api-ads-ruby/blob/master/adwords_api/examples/v201506/misc/use_runtime_config.rb with refresh token.
Any update on this issue?

from google-api-ads-ruby.

mcloonan avatar mcloonan commented on May 15, 2024

Thank you for the report, and I apologize that this slipped through the cracks. Since it seems @huydx may not be providing the pull request, I'll take a look at implementing a solution myself.

from google-api-ads-ruby.

Gataniel avatar Gataniel commented on May 15, 2024

@offthecuff Could you please be more specific? What is the exact place where did you provide expires_at?

from google-api-ads-ruby.

jstoks avatar jstoks commented on May 15, 2024

@Gataniel, It goes in the oauth2_token subsection of the authentication hash. Piggybacking off the example from @huydx , this is what i have:

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,
        :expires_at => 0
      }
    },
    :service => {
      :environment => 'PRODUCTION'
    }
  })

from google-api-ads-ruby.

jstoks avatar jstoks commented on May 15, 2024

This is the issue in a nutshell.

This method will return false if expires_at is nil.

def expired?
  return self.expires_at != nil && Time.now >= self.expires_at
end

At this point the client is not nil, but it will not be expired either so no token is created.

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

To me this honestly seems like a deficiency in the signet gem, but I suppose this might be the intended behavior.

from google-api-ads-ruby.

mcloonan avatar mcloonan commented on May 15, 2024

Since there's a workaround and the issue seems to be with Signet, I'm going to close this out. It might be worth filing a bug with Signet directly if this is still an issue for you.

from google-api-ads-ruby.

Related Issues (20)

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.