我在ruby / angularjs项目中安装了devise token auth和ng-token-auth,我正在尝试通过facebook / google进行身份验证。不成功,我得到下一个错误=>
{"errors":["Use POST /sign_in to sign in. GET is not supported."]}
我的服务器日志显示:
Started GET "/omniauth/facebook/callback?code=AQCJG_Oz26o9PADnpL_arsnTN5E38EFikWZDXiQHXEYki1wPNt4dkqpXHE_8SrbGbweh29VmGQleegapuvVf8jOQmVhtz1prLy7GLRr40i07O24M4iNY8WQFVqKD3TIRmqgsj-puaP61KzUdpR0LHw_yeeguX38FDV_4KjHAHa0D4OLipA6ofd78eXQoEhvdkvtFnguuJGfKt0N6eEj9m1h185F2jkZqaZAwh6lM_VQTnDiwOWy10IHYA62yXWk0MJv28AhhoszC-R7tdFvxAEwn6C7IsMhxY7aBZp6VJwegJyQBBydwXb5QpMnOi4oNLSvi6oKARQkQ5i8Mku5tcqTA&state=8bf6fcfb4dedcf2f22fa3bef875d0e91b63ac0c9b7a8f8a6" for ::1 at 2017-01-29 12:38:34 -0300
Processing by Devise::OmniauthCallbacksController#failure as HTML
Parameters: {"code"=>"AQCJG_Oz26o9PADnpL_arsnTN5E38EFikWZDXiQHXEYki1wPNt4dkqpXHE_8SrbGbweh29VmGQleegapuvVf8jOQmVhtz1prLy7GLRr40i07O24M4iNY8WQFVqKD3TIRmqgsj-puaP61KzUdpR0LHw_yeeguX38FDV_4KjHAHa0D4OLipA6ofd78eXQoEhvdkvtFnguuJGfKt0N6eEj9m1h185F2jkZqaZAwh6lM_VQTnDiwOWy10IHYA62yXWk0MJv28AhhoszC-R7tdFvxAEwn6C7IsMhxY7aBZp6VJwegJyQBBydwXb5QpMnOi4oNLSvi6oKARQkQ5i8Mku5tcqTA", "state"=>"8bf6fcfb4dedcf2f22fa3bef875d0e91b63ac0c9b7a8f8a6"}
Redirected to http://localhost:3000/api/v1/auth/sign_in
Completed 302 Found in 4ms (ActiveRecord: 0.0ms)
我的理解是我的应用程序正在启动Get方法而不是POST,但我该如何更改?
我一直在阅读有关此事的其他帖子,但没有人给出答案。
我的路线:
user_facebook_omniauth_authorize GET|POST /omniauth/facebook(.:format) omniauth_callbacks#passthru
user_facebook_omniauth_callback GET|POST /omniauth/facebook/callback(.:format) omniauth_callbacks#facebook
user_google_oauth2_omniauth_authorize GET|POST /omniauth/google_oauth2(.:format) omniauth_callbacks#passthru
user_google_oauth2_omniauth_callback GET|POST /omniauth/google_oauth2/callback(
谢谢。
编辑:我添加了我的客户端代码:
HTML(指向角度函数的简单链接)
<a class="btn btn-block btn-lg btn-social btn-facebook social-butt" ng-click="facebooksignup()"><span class="fa fa-facebook"></span> Regístrate con Facebook!</a>
我的angularjs控制器:
$scope.facebooksignup = function(){
$auth.authenticate('facebook')
.then(function(resp) {
// handle success
})
.catch(function(resp) {
// handle errors
});
我的模块配置:
app.config(function($authProvider) {
$authProvider.configure({
apiUrl: 'http://localhost:3000/api/v1',
validateOnPageLoad: false,
authProviderPaths: {
facebook: '/auth/facebook',
google: '/auth/google'
}
});
});