重定向 uri 不起作用
Redirect uri not working
我正在尝试使用 hwi oauth 包在 symfony2 中实现 oauth google 身份验证。我添加了按钮,弹出窗口打开并成功验证用户,然后在 javascript 中执行我的 signinCallback 函数。问题是我需要在登录操作后在数据库中注册用户,因此我为此配置了 redirect_uri。我使用 github 成功验证来测试操作,没有弹出窗口,只是创建一个 <a href="https://github.com/login/oauth/authorize?scope=user:email&client_id=MY_ID">Click here</a>
,然后重定向到该页面,然后在验证后将我重定向到正确的重定向 uri。 google 的问题在于,在成功通知后只调用 javascript 函数,而不是配置的 uri。有没有办法以与 github 相同的方式进行 google 认证?。我也尝试在 signinCallback 函数调用 document.location = "{{ url("hwi_oauth_service_redirect", {service: "google"}) }}"
中尝试,但当然会遇到一些与所需参数相关的错误。
如果对某人有帮助,我就是这样解决的:
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']);
}
}
我正在尝试使用 hwi oauth 包在 symfony2 中实现 oauth google 身份验证。我添加了按钮,弹出窗口打开并成功验证用户,然后在 javascript 中执行我的 signinCallback 函数。问题是我需要在登录操作后在数据库中注册用户,因此我为此配置了 redirect_uri。我使用 github 成功验证来测试操作,没有弹出窗口,只是创建一个 <a href="https://github.com/login/oauth/authorize?scope=user:email&client_id=MY_ID">Click here</a>
,然后重定向到该页面,然后在验证后将我重定向到正确的重定向 uri。 google 的问题在于,在成功通知后只调用 javascript 函数,而不是配置的 uri。有没有办法以与 github 相同的方式进行 google 认证?。我也尝试在 signinCallback 函数调用 document.location = "{{ url("hwi_oauth_service_redirect", {service: "google"}) }}"
中尝试,但当然会遇到一些与所需参数相关的错误。
如果对某人有帮助,我就是这样解决的:
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']);
}
}