2013-05-14 61 views
13

我正在開發模式下的Rails應用程序,它可以使用omniauth註冊。Oauth2 Instagram API「重定向URI與註冊重定向URI不匹配」

主機是

http://localhost:3000/ 

我使用的寶石:

gem 'omniauth' 
gem 'omniauth-foursquare' 
gem 'omniauth-instagram' 

當我通過omniauth註冊Foursquare的出現都沒有問題。所有的設置都是正確的,我在Foursquare開發人員設置中的redirect_uri等於主機(localhost:3000)

但是,如果我在Instagram客戶端管理器*中填寫完全相同的redirect_uri(localhost:3000)。 Instagram的給了我這樣的:

{ 
"code": 400, 
"error_type": "OAuthException", 
"error_message": "Redirect URI does not match registered    redirect URI" 
} 

基於此網址:

https://instagram.com/oauth/authorize?response_type=code&client_id=<ID>&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Finstagram%2Fcallback&state=18415adf24dd97873e61094f67c0fb7a94857fedf93e9d2e&scope=basic 

* enter image description here

我是什麼根據的Instagram,以及如何做錯了這應該是固定的?

+2

我自己修復了這個問題。添加了http:// localhost:3000/auth/instagram/callback作爲redirect_uri,它工作得很好。 – Biketire 2013-05-14 08:17:42

+0

請添加您的評論作爲答案,並將問題標記爲已回答。 – 2013-09-24 10:39:07

回答

19

我自己修復了這個問題。作爲redirect_uri增加了localhost:3000/auth/instagram/callback,它工作得很好。

+1

我不得不添加/ users/auth/instagram/callback – 2013-10-24 21:27:41

+0

有趣的是,auth/instagram /回調這實際上工作,曾經想過這是什麼原因? – pal4life 2014-09-30 22:46:15

+0

我也面臨同樣的問題。你能幫我嗎? – 2016-01-15 03:44:27

0

對於Drupagram模塊(Drupal的7)補充說:http://localhost:3000/instagram/oauth作爲REDIRECT_URI

5

我需要添加

http://localhost:3000/users/auth/instagram/callback 

爲我的回調URI,因爲我使用的設計。

0

對於任何有這個問題和重定向uri提供給instagram是完全一樣的,你使用的是,我發現有些用戶在我的instagram api上輸入我的網址爲http://www.example.com/loginhttp://example.com/login

然後我創建了一個php腳本來檢測字符串www是否存在於我的網址中,然後重新加載到同一頁面但沒有www

if(strpos($_SERVER['HTTP_HOST'], 'www.') !== FALSE) { 
    header("Location: ".str_replace('www.', '', $_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI'])); 
} 
-1

...或者你可以在這裏按照指示:

https://instagram.com/developer/authentication/?hl=en

請參閱 「步驟一:將您的用戶對我們的授權URL」 一節。

只需提供您的CLIENT_ID和REDIRECT_URI即可。

https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code 
0

問題:Instagram的的oauth2 API「重定向URI不匹配,註冊重定向URI

我的解決方案:請檢查NG-科爾多瓦 - oauth.js文件,並在檢查Instagram的功能。驗證redirect_uri的值與在Instagram的開發者控制檯上註冊您的應用程序相同。如果它相同,它可以正常工作,否則您會遇到上述問題。

3

當您指定重定向URI時http://localhost:3000http://localhost:3000/不同(請注意尾部斜線)。

確保回調URI完全匹配。

+1

這是答案,別看別處。 :) – Banago 2017-12-07 17:09:48

+0

這是唯一正確答案 – 2018-01-17 17:06:52

0

{ 「ERROR_TYPE」: 「OAuthException」, 「代碼」:400, 「ERROR_MESSAGE」: 「重定向URI不匹配,註冊重定向URI」}

如何從Instagram的

訪問令牌

https://adlivetech.com 有效的重定向的URI:https://adlivetech.com/

F於Instagram的註冊沙箱時CLIEN API https://www.instagram.com/developer/

這裏我們使用的網站URL網站url必須相同或直播網站,你可以通過使用https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=token

替換上述網址「客戶ID」與你的客戶ID 替換上述網址獲得訪問令牌容易「重定向-URI」重定向URL應該是你的域名,如:http://adlivetech.com

https://adlivetech.com/access_token=YOUR_ACCESS_TOken

相關問題