Welcome Guest, Not a member yet? Register   Sign In
Make Google API Request after Phil Sturgeon OAuth2
#1

[eluser]Unknown[/eluser]
I've implemented the OAuth2 spark by phil sturgeon and successfully returned userinfo. I want to now make an http request, specifically a request for a user's calendar metadata:

GET https://www.googleapis.com/calendar/v3/c...calendarId}

Here is the successful OAuth2 authentication controller:

public function session($provider)
{
$this->load->spark('oauth2/0.4.0');
$provider = $this->oauth2->provider($provider, array(
'id' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
));

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

redirect($url);
}
else
{
try
{
// Have a go at creating an access token from the code
$token = $provider->access($_GET['code']);

// Use this object to try and get some user details (username, full name, etc)
$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);
}
}

I can't figure out how to make an authorized call without the google client library. I've tried to make calls google client library but have not been able to combine the functionality of the library with this oauth code. Please help!




Theme © iAndrew 2016 - Forum software by © MyBB