An OAuth2 Server Library for PHP
Implement OAuth2.0 cleanly into your PHP application. Download the Code from GitHub to get started.
This library follows the zend PSR-0 standards. A number of
autoloaders exist which can autoload this library for that reason, but if you are not using one, you can register the
Using Composer? Execute the following command:
composer.phar require bshaffer/oauth2-server-php "~1.8"
This will add the requirement to the composer.json and install the library.
It is highly recommended you check out the
v1.8.0tag to ensure your application doesn’t break from backwards-compatibility issues. However, if you’d like to stay on the bleeding edge of development, you can set this to
Get Started With This Library
Looking through the cookbook examples is the best way to get started. For those who just skim the docs for code samples, here is an example of a bare-bones OAuth2 Server implementation:
$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password)); $server = new OAuth2\Server($storage); $server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); // or any grant type you like! $server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
See Main Concepts for more information on how this library works.
If you are new to OAuth2, I highly recommend the OAuth in 8 Steps screencast from Knp University:
Finally, consult the official OAuth2.0 documentation for the down-and-dirty technical specifications.
The best way to get help and ask questions is to file an issue. This will help answer questions for others as well.
If for whatever reason filing an issue does not make sense, contact Brent Shaffer (bshafs