Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用于在codeigniter中登录google的Oauth2_Php_Codeigniter_Oauth 2.0_Google Login - Fatal编程技术网

Php 用于在codeigniter中登录google的Oauth2

Php 用于在codeigniter中登录google的Oauth2,php,codeigniter,oauth-2.0,google-login,Php,Codeigniter,Oauth 2.0,Google Login,我正在尝试使用CodeIgniter对使用Google的用户进行身份验证 我安装了Spark并尝试了他在github中给出的使用示例 class Auth extends CI_Controller { public function session($provider) { $this->load->helper('url_helper'); $this->load->spark('oauth2/0.4.0');

我正在尝试使用CodeIgniter对使用Google的用户进行身份验证

我安装了Spark并尝试了他在github中给出的使用示例

class Auth extends CI_Controller {

    public function session($provider) {
        $this->load->helper('url_helper');

        $this->load->spark('oauth2/0.4.0');

        $provider = $this->oauth2->provider($provider, array(
            'id' => 'your-client-id',
            'secret' => 'your-client-secret',
        ));

        if (!$this->input->get('code')) {
            // By sending no options it'll come back here

            echo "Reaching here";

            $provider->authorize();
        } else {
            // Howzit?
            try {
                $token = $provider->access($_GET['code']);

                $user = $provider->get_user_info($token);

                // Here you should use this information to A) look for a user B) help a new user sign up with existing data.
                // If you store it all in a cookie and redirect to a registration page this is crazy-simple.
                echo "<pre>Tokens: ";
                var_dump($token);

                echo "\n\nUser Info: ";
                var_dump($user);
            } catch (OAuth2_Exception $e) {
                show_error('That didnt work: ' . $e);
            }
        }
    }

}
我的登录链接指向http://localhost/educonnect/auth/session/google

根据我的理解,它应该把我扔到谷歌的登录页面


但我看到一页回荡在这里。我做错了什么?

我查看了源代码,发现函数$provider->authorize;调用重定向。。。。但是,我无法找到函数重定向。。。。你的代码没有抛出任何错误吗?没有错误。如果我删除回音,它只会显示空白页。不确定如何调试。是否启用了错误报告?你有XDebug吗?如果是,请尝试使用Eclipse或Netbeans或任何支持XDebug的IDE调试重定向方法。