0

I am trying to use philsturgeon's OATH2 spark for CodeIgniter to authenticate a user using Google.

I installed the Spark and tried the Usage Example that he gives in the 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);
            }
        }
    }

}

My login link points to http://localhost/educonnect/auth/session/google

As per my understanding, it was supposed to throw me to the login page of google.

But I see a page which echoes "Reaching here". What am I doing wrong?

Community
  • 1
  • 1
aBhijit
  • 5,261
  • 10
  • 36
  • 56
  • I looked around in the source and noticed, that the function `$provider->authorize();` makes a call to `redirect(...)`. However, I wasn't able to locate the function `redirect(...)`. Doesn't your code throw any errors? –  Jan 14 '14 at 13:15
  • No errors. It just displays blank page if I remove the echo. Not sure how to debug. – aBhijit Jan 14 '14 at 15:21
  • Is error reporting enabled? http://stackoverflow.com/a/6575502/2897701 –  Jan 14 '14 at 16:27
  • Do you have XDebug? If yes, try to debug with Eclipse or Netbeans or any IDE, that supports XDebug, into the redirect method. –  Jan 16 '14 at 08:11

0 Answers0