FriendsOfSymfony/FOSOAuthServerBundle — pull request #57 by adrienbrault (2012-05-07 21:24:10+00:00)
Title: Fix error when using token endpoint with grant_type=client_credentials

Hey guys,

I was trying the client_credentials grant_type, but i ran into errors.
```FOS\OAuthServerBundle\Storage\OAuthStorage::createAccessToken``` throws an exception with $data=null ($data is the user).
Same thing happens to ```FOS\OAuthServerBundle\Storage\OAuthStorage::createRefreshToken```

Below the errors with the tests i added and without the fixes.
```
There were 2 errors:

1) FOS\OAuth2ServiceBundle\Tests\Storage\OAuthStorageTest::testCreateAccessTokenWithoutUser
InvalidArgumentException: Client has to implement the ClientInterface

FOSOAuthServerBundle/Storage/OAuthStorage.php:108
FOSOAuthServerBundle/Tests/Storage/OAuthStorageTest.php:133

2) FOS\OAuth2ServiceBundle\Tests\Storage\OAuthStorageTest::testCreateRefreshTokenWithoutUser
Argument 1 passed to FOS\OAuthServerBundle\Model\Token::setUser() must implement interface Symfony\Component\Security\Core\User\UserInterface, null given, called in FOSOAuthServerBundle/Storage/OAuthStorage.php on line 205 and defined

FOSOAuthServerBundle/Model/Token.php:136
FOSOAuthServerBundle/Storage/OAuthStorage.php:205
FOSOAuthServerBundle/Tests/Storage/OAuthStorageTest.php:242
```

This solution works for now well for me, and did not break existing tests.
I fixed the errors by the path that seemed obvious to me, feedback appreciated!