我試圖做一個春天啓動應用程序,將連接到使用彈簧社會Fitbit的API。我(中途)實現了ConnectionFactory
,它是Fitbit的依賴關係,並且試圖從我的應用程序中使用它。其中一部分涉及啓動ConnectController
來處理OAuth2「跳舞」。我的spring-social ConnectController有什麼問題?
當我嘗試在http://localhost:8080/connect
或http://localhost:8080/connect/fitbit
我重定向到whitelable錯誤頁面的消息,通過我的瀏覽器擊中ConnectController
:
有意外的錯誤(類型=不允許的方法,狀態= 405)。
請求方法「GET」不支持
我真的不明白我所看到的,但是當我設置DEBUG
級別的日誌記錄,並使用一些斷點,它看起來像打從瀏覽器的結果/connect
在春天試圖找到一種叫做connect/status
和擊球/connect/fitbit
結果在春天試圖找到一個名爲/connect/fitbitConnect
東西,然後努力使內部GET請求來/connect/connect/fitbitConnect
。
在這兩種情況下,它看起來像對應/connect
和/connect/{providerId}
上ConnectController
方法被調用罰款,那麼Spring炸彈當它尋找所有其他的東西。
這裏是SocialConfigurer
執行我使用它創建ConnectController
豆:
@Configuration
@EnableSocial
@PropertySource("${properties.path}/fitbot-service.properties")
public class SpringSocialConfig implements SocialConfigurer{
@Override
public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
connectionFactoryConfigurer.addConnectionFactory(new FitbitConnectionFactory(
environment.getProperty("fitbit.clientId"),
environment.getProperty("fitbit.clientSecret")
));
}
@Override
public UserIdSource getUserIdSource() {
return new SessionUserIdSource();
}
@Override
public UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) {
return new InMemoryUsersConnectionRepository(connectionFactoryLocator);
}
@Bean
public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) {
return new ConnectController(connectionFactoryLocator, connectionRepository);
}
}
這到底是怎麼回事呢?我究竟做錯了什麼?
(1/2)感謝您也看看這個問題。對此,我真的非常感激。我會考慮添加這些視圖。關於應用程序:我是Target的顧問,他們讓我們做創新衝刺。我的teem上的每個人都適合步數比賽,我們希望獲得有關Hubot傾倒在hipchat中的排名信息。 Spring-social-fitbit是我模仿其他春季社交項目的嘗試。目標可能會讓我們發佈源代碼(這是我們的目標),但我認爲它不會很有用 – David
(2/2)我不認爲我們的spring-social-fitbit會是有用的貢獻有以下幾個原因:(1)我們只建立足夠的功能來獲得步驟信息,(2)我幾乎不知道自己在做什麼,(3)我們可能不會完成。 這就是說,我覺得這個東西足夠有趣,我會考慮分叉/重新啓動這個社區項目。如果我能爲Spring做出實質性貢獻並深入研究這種OAuth,那將是最酷的事情。 – David