2014-03-12 98 views
1

我有一個關於Spring Social的問題。 ProviderSigninController的文檔說:春季社交:提供商登錄控制器

當經由一個OAuth 2提供商認證,ProviderSignInController支持以下流程:

**1 -** POST /signin/{providerId} - Initiates the sign in flow by redirecting to 
     the provider's authentication endpoint. 

**2 -** GET /signin/{providerId}?code={verifier} - Receives the authentication 
     callback from the provider, accepting a code. Exchanges this code for an 
     access token. Using this access token, it retrieves the user's provider 
     user ID and uses that to lookup a connected account and then 
     authenticates to the application through the sign in service. 

    **2-a** If the provider user ID doesn't match any existing connection, 
     ProviderSignInController will redirect to a sign up URL. The default sign 
     up URL is "/signup" (relative to the application root), but can be 
     customized by setting the signUpUrl property. 

    **2-b** If the provider user ID matches more than one existing connection, 
     ProviderSignInController will redirect to the application's sign 
     in URL to offer the user a chance to sign in through another provider 
     or with their username and password. The request to the sign in URL will 
     have an "error" query parameter set to "multiple_users" to indicate 
     the problem so that the page can communicate it to the user. The default 
     sign in URL is "/signin" (relative to the application root), 
     but can be customized by setting the signInUrl property. 

    **2-c** If any error occurs while fetching the access token or while fetching 
     the user's profile data, ProviderSignInController will redirect to the 
     application's sign in URL. The request to the sign in URL will have an 
     "error" query parameter set to "provider" to indicate an error occurred 
     while communicating with the provider. The default sign in URL is 
     "/signin" (relative to the application root), but can be customized by 
     setting the signInUrl property. 

這意味着,我必須/登入映射到視圖?

參考:http://docs.spring.io/spring-social/docs/1.1.0.M4/reference/html/signin.html

更新:我修改了configuration.So我在配置申請網址和signinurl指定。現在我面對一個錯誤問題,我不明白。 我的oAuth舞步走到了2-c,但是我重定向到了signinurl,並且error = provider。這是關於提供者的錯誤。當我諮詢日誌時,我有以下消息:

[org.springframework.social.connect.web.ProviderSignInController] [] http-bio-8080-exec-10 Exception while handling OAuth2 callback (No Session found for current thread). Redirecting to /login 

哪個會話是關於?我不明白。 這裏是完整的日誌文件http://pastebin.com/wzL4ZQFk

+0

我認爲這意味着控制器處理'/ signin'視圖,但是你負責'/ signup'視圖。 – CodeChimp

+0

它在我看來像登錄工作,但你的應用程序失敗,當它試圖持續連接。你正在使用數據庫還是內存中的持久性? – Alex

回答

0

不,在發送到/ signin/{providerId}時,您將被重定向到facebook,twitter,google或'providerId'中指定的任何提供者的身份驗證屏幕。