GithubHelp home page GithubHelp logo

bkosun / kohana-socialite Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 23 KB

OAuth authentication for Kohana PHP Frmework

License: MIT License

PHP 100.00%
kohana kohana-3 kohana-php-framework koseven oauth oauth2

kohana-socialite's Introduction

Kohana Socialite

The Kohana Socialite module provides an expressive, fluent interface to OAuth authentication.

Getting Started

  1. Download the module into your modules subdirectory.
  2. Enable the module in your bootstrap file:
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
// ...
  'socialite'       => MODPATH.'socialite',
));
  1. Make sure the settings in config/socialite.php are correct for your environment. If not, copy the file to application/config/socialite.php and change the values accordingly.

Usage

class Controller_Auth extends Controller
{
    public function action_login()
    {
        $socialite = Socialite::factory()
            ->driver('Facebook')
            ->redirect_url(Route::url('auth', array('action' => 'callback',)));

        $socialite->redirect();
    }

    public function action_callback()
    {
        $socialite = Socialite::factory()
            ->driver('Facebook')
            ->redirect_url(Route::url('auth', array('action' => 'callback',)));
        
        try 
        {
            $user = $socialite->user();
        } 
        catch (Socialite_Exception $e) 
        {
            throw new Kohana_Exception($e->getMessage());
        }
        
        // Retrieving User Details
        $id = $user->get_id();
        $nickname = $user->get_nickname();
        $first_name = $user->get_first_name();
        $surname = $user->get_surname();
        $birthday = $user->get_birthday();
        $gender = $user->get_gender();
        $photo = $user->get_photo();
        $email = $user->get_email();
        $phone = $user->get_phone();
        $website = $user->get_website();
        $profile = $user->get_profile();
    }
}

Providers

  • Facebook
  • Instagram
  • Mail
  • Odnoklassniki
  • Vkontakte

Acknowledgements

The author drew extensive inspiration from the Laravel Socialite package and its related documentation.

License

This package is open-sourced software licensed under the MIT license

kohana-socialite's People

Contributors

bkosun avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.