我试图用hwi oauth bundle在symfony2中实现oauth google身份验证。我添加了按钮和弹出窗口打开并succesfull autenticate用户,然后在javascript中执行我的signinCallback函数。问题是我需要在登录操作之后在数据库中注册用户,所以我为此配置了redirect_uri。我使用github的成功验证测试动作,没有弹出窗口,只是创建一个<a href="https://github.com/login/oauth/authorize?scope=user:email&client_id=MY_ID">Click here</a>
,并重定向到该页面,并在验证之后将我重定向到正确的重定向uri。谷歌的问题是,成功的atentication后,只调用JavaScript函数,而不是配置的uri。有没有一种方法可以用github的相同方式进行google验证?我也尝试在signinCallback函数中调用document.location = "{{ url("hwi_oauth_service_redirect", {service: "google"}) }}"
,但是当然得到一些与所需参数有关的错误。重定向uri不工作
1
A
回答
1
如果帮助别人这就是我如何解决:
function signinCallback(authResult) {
if (authResult['access_token']) {
// Properly authorized
// Hide the button
document.getElementById('customBtn').setAttribute('style', 'display: none');
document.location = "{{ url("hwi_oauth_service_redirect", {service: "google"}) }}";
} else if (authResult['error']) {
// If error
// console.log('There was an error: ' + authResult['error']);
}
}
相关问题
- 1. Pinterest OAuth重定向Uri不工作
- 2. 的Instagram:重定向URI不匹配,注册重定向URI
- 3. AJAX重定向不工作
- 4. HTTPS重定向不工作
- 5. Angular.js - 重定向不工作
- 6. 重定向301不工作
- 7. 重定向不工作
- 8. 重定向回不工作
- 9. PLayframework重定向不工作
- 10. 重定向不工作
- 11. URL重定向不工作
- 12. Android重定向uri
- 13. php重定向不工作,但......工作......?
- 14. Oauth2 Instagram API“重定向URI与注册重定向URI不匹配”
- 15. htaccess自定义重定向不工作
- 16. 绑定重定向工作不正常
- 17. Google API重定向URI无法正常工作
- 18. 非www不工作,301不重定向
- 19. 获取重定向的URI
- 20. heroku重定向uri虚假
- 21. URI方案重定向
- 22. NGINX中的URI重定向
- 23. Facebook无效重定向URI
- 24. Google +重定向URI错误
- 25. Instagram的API - 重定向URI
- 26. .htaccess重定向重定向301不能正常工作
- 27. 301重定向,一个重写工作,另一个不工作
- 28. Outlook日历api重定向uri与虚拟主机,不能正常工作
- 29. htaccess 301重定向不工作
- 30. mod_rewrite后不工作[R:重定向]出