PHPackages                             binhvd/oauth2-server-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. binhvd/oauth2-server-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

binhvd/oauth2-server-bundle
===========================

Symfony OAuth2ServerBundle

v0.5.1(4y ago)0194MITPHPPHP &gt;=5.3

Since Mar 31Pushed 4y agoCompare

[ Source](https://github.com/binhvd/oauth2-server-bundle)[ Packagist](https://packagist.org/packages/binhvd/oauth2-server-bundle)[ Docs](https://github.com/binhvd/oauth2-server-bundle)[ RSS](/packages/binhvd-oauth2-server-bundle/feed)WikiDiscussions develop Synced 1w ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

OAuth2 Server Bundle
====================

[](#oauth2-server-bundle)

OAuth2 Server Bundle for Symfony 2, built on the [oauth2-server-php](https://github.com/bshaffer/oauth2-server-php) library.

[![Build Status](https://camo.githubusercontent.com/ec9d900b98ca100d9a1f7ccb644d5ae9de8d298931141396ca26c24a08d64156/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f62736861666665722f6f61757468322d7365727665722d62756e646c652e706e67)](http://travis-ci.org/bshaffer/oauth2-server-bundle)

Getting Started
---------------

[](#getting-started)

See the [Complete Documentation](http://bshaffer.github.io/oauth2-server-php-docs/) for information regarding the OAuth2.0 protocol and the PHP library used by this bundle to implement it.

For documentation specific to this bundle, continue reading below.

Bundle Overview
---------------

[](#bundle-overview)

The following grant types are supported out the box:

- Client Credentials
- Authorization Code
- Refresh Token
- User Credentials (see below)

You can make token requests to the `/token` path via POST.

You can restrict the grant types available per client in the database, use a Compiler Pass or in your own TokenController you could do something like:

```
public function tokenAction()
{
    $server = $this->get('oauth2.server');

    // Override default grant types to authorization code only
    $server->addGrantType($this->get('oauth2.grant_type.authorization_code'));

    return $server->handleTokenRequest($this->get('oauth2.request'), $this->get('oauth2.response'));
}
```

Installation
------------

[](#installation)

### Step 1: Add package to Composer

[](#step-1-add-package-to-composer)

Use composer to add the requirement and download it by running the command:

```
$ php composer.phar require bshaffer/oauth2-server-bundle
```

Composer will update your composer.json and install the bundle to your project's `vendor/bshaffer` directory.

### Step 2: Enable the bundle

[](#step-2-enable-the-bundle)

Enable the bundle in the kernel:

```
