2014-10-07 69 views
1

我使用Google Auth進行身份驗證和授權。現在,當只有一個用戶在瀏覽器中登錄Google並且之前已通過身份驗證時,它會自動登錄。ServiceStack編輯Google Oauth授權網址

此文章Force google account chooser指向向Google Oauth授權網址添加參數(prompt = select_account)以強制要出現的帳戶選擇列表。

這使我想到我的問題,有什麼辦法可以編輯或追加到使用ServiceStack進行身份驗證請求時使用的此URL?註冊供應商時

<appSettings> 
    <add key="oauth.GoogleOAuth.AuthorizeUrl" 
     value="https://accounts.google.com/o/oauth2/auth?prompt=consent"/> 
</appSettings> 

或者如果你喜歡,代碼:

回答

1

你可以改變被使用任何AuthProvider無論是在你的Web.configAuthorizeUrl

Plugins.Add(new AuthFeature(
    () => new CustomUserSession(), 
    new IAuthProvider[] { 
     //... 
     new GoogleOAuth2Provider(appSettings) { 
      AuthorizeUrl = "https://accounts.google.com/o/oauth2/auth?prompt=consent" 
     } 
    })); 
+0

非常感謝。立即工作。 – 2014-10-07 21:47:52