title: oauth2-client for Google working in Codeigniter
body: <p>Hi got a bit problem and I can't find any lead, here it goes</p>
  
  <p>I'm working with OAuth2-client from <a href="https://github.com/thephpleague/oauth2-client" rel="nofollow noreferrer">here</a> and I'm doing it in codeigniter</p>
  
  <p>this is my controller : </p>
  
  <pre><code>public function index()
      {
          include(APPPATH.'libraries/League/OAuth2/Client/Provider/IdentityProvider.php');
          include(APPPATH.'libraries/League/OAuth2/Client/Provider/Google.php');
          $provider = new League\OAuth2\Client\Provider\Google(array(
          'clientId'  =&gt;  '********************.apps.googleusercontent.com',
          'clientSecret'  =&gt;  '**************************',
          'redirectUri'   =&gt;  '**************************/oauth2callback'
      ));
  
      if ( ! isset($_GET['code'])) {
  
          // If we don't have an authorization code then get one
          $provider-&gt;authorize();
  
      } else {
  
          try {
  
              // Try to get an access token (using the authorization code grant)
              $t = $provider-&gt;getAccessToken('authorization_code', array('code' =&gt; $_GET['code']));
  
              // NOTE: If you are using Eventbrite you will need to add the grant_type parameter (see below)
              // $t = $provider-&gt;getAccessToken('authorization_code', array('code' =&gt; $_GET['code'], 'grant_type' =&gt; 'authorization_code'));
  
              try {
  
                  // We got an access token, let's now get the user's details
                  $userDetails = $provider-&gt;getUserDetails($t);
  
                  foreach ($userDetails as $attribute =&gt; $value) {
                      var_dump($attribute, $value) . PHP_EOL . PHP_EOL;
                  }
  
              } catch (Exception $e) {
  
                  // Failed to get user details
  
              }
  
          } catch (Exception $e) {
  
              // Failed to get access token
  
          }
      }
  
      }
  </code></pre>
  
  <p>I get the OAuth class and save it to my library folder</p>
  
  <p>Somehow I manage to open the google "Choose Account" or "login" and the request for permission this <img src="https://i.stack.imgur.com/bmMHt.jpg" alt="enter image description here"></p>
  
  <p>but when I click Accept the page reload to this <br> <code>url https://mysite.com/oauth2callback?state=****&amp;code=***</code></p>
  
  <p>and that is 404 in my end. </p>
  
  <p>does anyone have better solution to this, could anyone help me.
  this is my 1st try using OAUTH and working in google app engine so please spare me. Thanks in advance.</p>