Coinbase Connect (OAuth2) allows a user to grant access to an App either for a specific account or for all accounts owned by the user.
The choice depends on the account parameter on OAuth2 authorization URL (default value = select
to grant access to a single account).
I need to use account=all
Anyone know where I can set this in Devise ?
I've tried :
In config/initializers/devise.rb
:
config.omniauth :coinbase, ENV['COINBASE_CLIENT_ID'], ENV['COINBASE_SECRET_ID'], scope: 'wallet:user:email wallet:accounts:read wallet:payment-methods:read wallet:sells:create wallet:withdrawals:create', account: :all
But this didn't change the authorization URL
And then I tried adding the parameter in the omniauth_authorize_path in the app/views/pages/profile.html.erb
<button class="d-flex justify-content-between align-items-center pr-4 coinbase-btn">
<%= image_tag 'logo-coinbase-white.svg', class: "coinbase-logo" %>
<%- User.omniauth_providers.each do |provider| %>
<%= link_to "Connect your #{OmniAuth::Utils.camelize(provider)} Wallet",
omniauth_authorize_path(current_user, provider, account: 'all') %>
<% end %>
</button>
(This is the page where I want users to link their coinbase account with their account on my app)
Looking in to the omniauth-coinbase
gem that I'm using , I figured the list of options we can pass is defined here at line 30 :
Line 30 : option :authorize_options, [:scope, :meta]
This line specifies which options we can use.
I thus forked the gem and added :account to the list of authorized options
Then I was able to pass it in my devise.rb
config.omniauth :coinbase,
ENV['COINBASE_CLIENT_ID'],
ENV['COINBASE_SECRET_ID'],
scope: 'wallet:user:email wallet:accounts:read wallet:payment-methods:read wallet:sells:create wallet:withdrawals:create',
account: 'all'