[英]Ruby on Rails - Devise Omniauth - Coinbase Strategy - Pass account parameter
Coinbase Connect (OAuth2)允許用戶為特定帳戶或用戶擁有的所有帳戶授予對應用程序的訪問權限。
選擇取決於 OAuth2 授權 URL 上的帳戶參數(默認值 = select
以授予對單個帳戶的訪問權限)。
我需要使用account=all
任何人都知道我可以在 Devise 的哪里設置它?
我試過了:
在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
但這並沒有改變授權 URL
然后我嘗試在app/views/pages/profile.html.erb
的 omniauth_authorize_path 中添加參數
<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>
(這是我希望用戶將他們的 coinbase 帳戶與他們在我的應用程序上的帳戶相關聯的頁面)
查看我正在使用的omniauth-coinbase
gem,我發現我們可以傳遞的選項列表在第30行定義:
第 30 行: option:authorize_options, [:scope, :meta]
此行指定我們可以使用哪些選項。
因此,我將 gem 分叉並添加:account 到授權選項列表中
然后我可以在我的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'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.