caseyamcl/oauthsupport

This package is abandoned and no longer maintained. The author suggests using the league/oauth2-client package instead.

An OAUTH 2.0 Client Library

v1.0 2012-12-10 21:25 UTC

This package is auto-updated.

Last update: 2022-02-01 20:49:12 UTC


README

!! NOTICE !!: This package has been abandoned. The author recommends you use league/oauth2-client instead

An OAuth 2.0 client library (draft 10 / specification 1), forked from https://github.com/vznet/oauth_2.0_client_php, written by Charron Pierrick and Berejeb Anis

LICENSE

This Code is released under the GNU LGPL

Please do not change the header of the file(s).

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU Lesser General Public License for more details.

Installation

Via composer/packagist:

require {
    ...
    'caseyamcl/Oauthsupport': 'dev-master'
}

Usage

This library includes an abstract class named 'AuthService', which can be extended to create OAuth 2.0 clients for specific services.

As an example, a Facebook and Google class are included in the code. These classes are fully functional, and can be used in production.

To create your own client, create a class that extends the Oauth2\AuthService abstract class:

class MyOauthClient extends \Oauth2\AuthService
{
    /**
     * Get the Authorization URL
     * 
     * @return string
     */
    public function getAuthUrl()
    {
        return "http://SOME/URL/To/Authorization/Endpoint";
    }

    /**
     * Get the token URL
     * 
     * @return string
     */
    public function getTokenUrl()
    {
        return "http://SOME/URL/To/Token/Endpoint";
    }

    /**
     * Get info once logged-in
     * 
     * @param string $accessToken
     * @return array  Array of info
     */
    public function getInfo($accessToken)
    {
        $infoUrl = 'http://SOME/URL/To/Api/Stuff';
        $this->client->setAccessToken($accessToken);
        return $this->client->get($infoUrl);
    }        
}