For convention reasons I would like to initialize the Fitgem client in config/initializers/fitgem.rb. When I say initialize I mean pass in my app's consumer token and consumer secret like so:

Fitgem.configure do |config|
  config.consumer_key        = "XXXX"
  config.consumer_secret     = "XXXX"
  config.token               = "XXXX"
  config.secret              = "XXXX"
end

This is the exact same manner that is done with Facebook and Twitter clients (https://github.com/sferik/twitter) elsewhere. Is there a similar way I can do this with Fitgem?

The error I receive when I try to initialize the client this way is:

undefined method `configure' for Fitgem:Module

The fitgem docs (http://www.rubydoc.info/github/whazzmaster/fitgem/frames) say to do it like this:

client = Fitgem::Client.new {
  :consumer_key => my_key,
  :consumer_secret => my_secret,
  :token => fitbit_oauth_token,
  :secret => fitbit_oauth_secret
}

But I don't want to have to re-initialize the Fitgem client in every method.

So, number 1, I would love to know how to do this, and number 2 I would love to know how to look at the fitgem code to see that configure is not an acceptable method.

有帮助吗?

解决方案

Maybe it's been out of date to answer, but now there is omniouth for fitbit. It's not so difficult to use the gem because there is the explanation about how to do the configuration. You have to make omniauth.rb file under config/initializers and place the consumer_key and consumer_secret there.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top