Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fuel oAuth2 Package

tag: 0.0.1

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 classes
Octocat-spinner-32 README.md
Octocat-spinner-32 bootstrap.php
README.md

Fuel oAuth2

Authorize users with your application in a driver-base fashion meaning one implementation works for multiple oAuth 2 providers.

Note that this Cell ONLY provides the authorization mechanism. You will need to implement the example controller so you can save this information to make API requests on the users behalf.

Currently Supported

  • Facebook

TODO

This is just a prototype and so far only works with Facebook, meaning beyond implementing more providers it might just not work with others, so refactoring is going to be important.

Also, requests need to be WAY more bullet-proof, but there is no generic Request class in Fuel, which is something else that needs to be worked on.

Usage Example

http://example.com/auth/session/facebook

public function action_session($provider)
{   
    $foo = OAuth2_Provider::factory($provider, array(
        'client_id' => 'yourappid',
        'client_secret' => 'your-facebook-secret',
    ));

    if ( ! isset($_GET['code']))
    {
        // By sending no options it'll come back here
        $foo->authorize();
    }

    else
    {
        // Howzit?
        try
        {
            $params = $foo->access($_GET['code']);

            $user = $foo->get_user_info($params['access_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>";
            var_dump($user);
        }

        catch (OAuth2_Exception $e)
        {
            show_error('That didnt work: '.$e);
        }

    }
}
Something went wrong with that request. Please try again.