2014-05-25 41 views
1

谷歌應用市場#5最佳實踐表示,在管理員安裝應用後,用戶不應該看到同意屏幕。我一直在嘗試使用devise和omniauth-google-oauth2來進行身份驗證的Rails應用程序。我使用管理員帳戶在測試域中設置了應用程序。但非管理員用戶總是看到同意屏幕。任何想法如何避免它? https://github.com/zquestz/omniauth-google-oauth2有一些幫助;但是設置那裏指定的任何選項都沒有幫助。非管理員用戶繞過範圍同意屏幕

我的配置看起來像如下:

config.omniauth :google_oauth2, "code", "code", { access_type: "online", approval_prompt: "none", include_granted_scopes: "true", prompt: "select_account" } 

指定像 「電子郵件,個人主頁上,日曆,https://www.google.com/m8/feeds/」 範圍提供了以下錯誤:

Error: invalid_scope 

Some requested scopes were invalid. {valid=[https://www.googleapis.com/auth/calendar, https://www.google.com/m8/feeds/], invalid=[https://www.googleapis.com/auth/profile, https://www.googleapis.com/auth/email], noncanonical=[https://www.google.com/m8/feeds/(https://www.googleapis.com/auth/contacts)]} 

回答

1

添加

https://www.googleapis.com/auth/plus.me

在「谷歌Apps Marketplace中SDK」的範圍列表來解決這個問題。當域管理​​員安裝應用程序的其餘部分時,用戶將看不到同意屏幕。

即使我的omniauth配置現在簡化了。它看起來像如下:

config.omniauth :google_oauth2, "XXX.apps.googleusercontent.com", "YYY", { access_type: "online", approval_prompt: "none", include_granted_scopes: "true" } 
0

關於invalid_scope錯誤,我認爲你需要使用以下示波器進行配置文件和電子郵件

https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile

僅供參考使用https://developers.google.com/oauthplayground/找出有效範圍爲其他谷歌API的

+0

這解決了invalid_scope問題。謝謝。但是所有用戶都表示同意屏幕的主要問題仍然存在。 – Subbu

+0

您是否已將所有這些範圍添加到開發人員控制檯中的Google Apps Marketplace SDK頁面? https://developers.google.com/apps-marketplace/preparing –

+0

是的,我添加了所有範圍,它們與oAuth2請求的一部分發送的內容完全相同。 – Subbu