![](/img/trans.png)
[英]Sign in with Yammer is using 'http' instead of 'https' so fails with 'Invalid Redirect URI' error
[英]stripe callback redirecting http instead https uri
我在網站上使用Stripe Connect,當生產中的用戶嘗試將其Stripe帳戶連接到我的網站時,Stripe回調中出現以下錯誤:
{
"error": "invalid_redirect_uri",
"error_description": "Invalid redirect URI 'http://www.mywebsite.com/stripe_connections/callback'. Ensure this uri exactly matches one of the uris specified in your application settings",
"state": "4 »
}
而我的條紋應用程序設置中的redirecti URIS是https://www.mywebsite.com/stripe_connections/callback
這是我的控制器:
require 'oauth2'
class StripeConnectionsController < ApplicationController
skip_after_action :verify_authorized
def new
stripe_auth_url = "https://connect.stripe.com/oauth"
client = OAuth2::Client.new(ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET_KEY'], :site => stripe_auth_url)
@stripe_url = client.auth_code.authorize_url(:redirect_uri => "#{request.protocol}#{request.host_with_port}/stripe_connections/callback", :scope => 'read_write', state: params[:brief_id])
end
def callback
@brief = Brief.find(params[:state])
stripe_auth_url = "https://connect.stripe.com/oauth"
@user = current_user
client = OAuth2::Client.new(ENV['STRIPE_CONNECT_CLIENT_ID'], ENV['STRIPE_SECRET_KEY'], :site => stripe_auth_url)
access_token = client.auth_code.get_token(params[:code], :redirect_uri => '#{request.protocol}#{request.host_with_port}/oauth2/callback')
stripe_connection = StripeConnection.find_or_create_by(user_id: @user.id)
stripe_connection.update_attributes(access_token: access_token.token,
refresh_token: access_token.refresh_token,
livemode: access_token.params['livemode'],
stripe_user_id: access_token.params['stripe_user_id'],
publishable_key: access_token.params['stripe_publishable_key']
)
@user.profile.projects.where(state: 'pending').update_all(state: "on_sale")
end
end
我正在使用heroku並已經支付了SSL附加組件。 我不知道為什么Stripe返回http而不是https。 有人有主意嗎? 謝謝。
ps:這已經在生產中使用過,並且可以在網站的beta版本中使用
用戶是否單擊按鈕以連接到條帶? 我剛剛刪除了redirect_uri參數。
您必須在new
方法中刪除client.auth_code.authorize_url()
的redirect_uri
,在callback
方法中還要刪除redirect_uri
, client.auth_code.authorize_url()
在client.auth_code.authorize_url()
中放置正確的協議。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.