2017-10-11 410 views
0

我無法爲我的Meteor應用程序配置Google OAuth。如何解決Google OAuth「redirect_uri_mismatch」錯誤?

幾周前,當它成功完成時,我成功地完成了它,但現在突然間,我似乎無法正確配置它。

我已經隧道通過ngrok我的應用程序。我會一步一步給你說明我如何去設定這一點。請指出做錯了什麼,以及我能做些什麼來糾正這一點。

我開始在我的終端。我用火起來的應用:

meteor --port 7000 

我打開另一個終端和火起來ngrok使用:

./ngrok http 7000 

這就產生

ngrok starts a tunnel to my app

在我Meteor.startup我添加以下代碼:

../clien T/main.js

Meteor.startup(function() { 
    // Client startup method. 

    METEOR_OFFLINE_CATALOG=1; 
    METEOR_PROFILE=1; 

    Meteor.absoluteUrl.defaultOptions.rootUrl ='http://41958975.ngrok.io'; 
    // 
}); 

在我的瀏覽器控制檯時,I型:

Meteor.absoluteUrl() 

我得到 The response I get in my browser console showing the absoluteURL

我現在http://41958975.ngrok.io鏈接粘貼到瀏覽器,並得到這個:

The entry point into the configuration of google OAuth

單擊按鈕後跟:

the configuration of google AOuth

由於1到5之前已經完成的步驟,我直接跳到步驟6,7和8。

The results of configuring steps 6, 7 and 8

...並通過粘貼客戶端ID和客戶端完成祕密

The complete filled in configuration form

然後點擊保存配置。結果是:

a successful configuration

現在,當我在與谷歌按鈕點擊標誌:此彈出,就像它應該發生的。

enter image description here

我點擊的帳戶選項之一。這就是一切都會變成現實!我重定向回在與谷歌按鈕(登錄頁面)與顯示

Internal error message

此錯誤消息望着終端,我也收到此錯誤信息:

terminal error message

我似乎無法超越這一點。 我在做什麼錯,我怎麼能超越這一點?

期待您的幫助。

+0

好像你已經有這個問題:https://stackoverflow.com/questions/39860152/how-do-use-ngrok-在-結合與 - 谷歌-的OAuth – Styx

回答

0

當您運行應用程序時,忘記修改ROOT_URL。你最後的屏幕截圖的第一行清楚地表明它:

App running at: http://localhost:7000/

設置absoluteUrl客戶不會幫助,因爲它是你的服務器誰試圖獲得令牌。

uses OAuth._redirectUri() function得到redirect_uri,和那裏的Meteor.absoluteUrl() is used(它從ENV變量ROOT_URL,如documentation說明)。

因此,你的redirect_uri變得http://localhost:7000/_oauth/google顯然與http://41958975.ngrok.io/_oauth/google(步驟#7)的錯配。

爲了解決這個問題,你應該這樣開始你的流星應用:

ROOT_URL="http://41958975.ngrok.io" meteor 
相關問題