簡體   English   中英

Bigcommerce redirect_uri_mismatch oauth2錯誤

[英]Bigcommerce redirect_uri_mismatch oauth2 error

我無法在登台/制作服務器中使用bigcommerce oauth授權我的rails應用程序。 使用ngrok在開發中使用相同的配置/代碼。

收到錯誤消息:( bigcommerce)身份驗證失敗! invalid_credentials:OAuth2 :: Error,redirect_uri_mismatch:參數redirect_uri與注冊的URI不匹配{“error”:“redirect_uri_mismatch”,“error_description”:“參數redirect_uri與注冊的URI不匹配”}

這是應用程序發送到bigcommerce登錄服務器的內容:

https://login.bigcommerce.com/oauth2/authorize?client_id=XXX&context=XXX&redirect_uri=https%3A%2F%2Fexample.com%2Fauth%2Fbigcommerce%2Fcallback&response_type=code&scope=store_v2_orders_read_only+store_v2_products_read_only+store_v2_customers_read_only+store_v2_information_read_only

然后Bigcommerce調用app回調:

https://example.com/auth/bigcommerce/callback?code=dwud9qmc7wxehy5cd9da6avfy96yp7k&context=XXX&scope=store_v2_orders_read_only+store_v2_products_read_only+store_v2_customers_read_only+store_v2_information_read_only

我很確定redirect_uri傳遞給登錄服務器與我在我的應用程序回調網址(復制粘貼)中輸入的相同。

寶石使用:寶石'設計','〜> 2.2.4'寶石'omniauth-bigcommerce'gem'bigcommerce',:github =>'mechatama / bigcommerce-api-ruby',: branch =>'oauth'

我錯過了什么嗎? 過去幾天我一直在尋找解決方案。

您需要在devise.rb上添加基於環境的重定向uri

example :
setup: (lambda do |env|
      request = Rack::Request.new(env)
      env['omniauth.strategy'].options['token_params'] = {:redirect_uri => 'http://localhost:81/users/auth/google_oauth2/callback'}
      # http://e3a098b5.ngrok.io/users/auth/google_oauth2/callback
    end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM