I'm writing a little app for Coinbase and I'm making an initializer that I've thrown in omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :coinbase, ENV["COINBASE_CLIENT_ID"], ENV["COINBASE_CLIENT_SECRET"], scope: "sell send transfers user"
end
I want to be able to access this anywhere in my app so that I can create an access_token for the user. Based on their docs and the research I've done into Omniauth, I'm not quite sure how to do this.
Should I throw an instance variable and an =
in front of the code posted above? Is that a correct solution? Also, how do I go about getting an access_token after initializing this?
Thanks!
Check out this section in the omniauth docs: https://github.com/intridea/omniauth#integrating-omniauth-into-your-application
You first want to set your OAuth redirect URL on Coinbase to /auth/coinbase/callback. Then, when users are redirected back to your site at that path with the code OmniAuth will do its magic and set a special hash called the Authentication Hash on the Rack environment which contains some info about the user as well as the OAuth credentials.