1

I'm using zf2 apigility in my web application. With production mode, if config_cache_enabled is true in config/application.config.php, I get this message error when requesting access_token:

The storage configuration for OAuth2 is missing

If I set it to false, I get my access token.

So my problem is to have config_cache_enabled set to true and a successful request for getting the access token in production mode, due to best performance when configuration is cached. How to do that ?

This is my zf-mvc-auth configuration :

'zf-mvc-auth' => array(
        'authentication' => array(
            'adapters' => array(
                'CustomStorage' => array(
                    'adapter' => 'ZF\\MvcAuth\\Authentication\\OAuth2Adapter',
                    'storage' => array(
                        'storage' => 'Application\\Adapter\\OAuth\\CustomPdoAdapter',
                        'route' => '/oauth',
                    ),
                ),
            ),
        ),
    ),

This is my oauth2.local.php :

'zf-oauth2' => array(
        'db' => array(
            'dsn'      => 'mysql:dbname=mydatabase;host=localhost',
            'username' => 'root',
            'password' => '',
        ),
        'allow_implicit' => true,
        'access_lifetime' => 3600,
        'enforce_state'  => true,
        'storage'        => 'Application\Adapter\OAuth\CustomPdoAdapter',
        'storage_settings' => array(
           'user_table' => 'users',
        ),
         'options' => array(
            'always_issue_new_refresh_token' => true,
        ),
    ),

I think it is well configured.

Vern Burton
  • 3,215
  • 1
  • 18
  • 31
Hasina
  • 335
  • 3
  • 13

2 Answers2

1

Did you setup your zf-mvc-auth correctly. In the module.config.php you can read that you have to define a storage key. There is also written how you can do this:

To specify the storage instance, you may use one of two approaches:

  • Specify a "storage" subkey pointing to a named service or an array of named services to use.
  • Specify an "adapter" subkey with the value "pdo" or "mongo", and include additional subkeys for configuring a ZF\OAuth2\Adapter\PdoAdapter or ZF\OAuth2\Adapter\MongoAdapter, accordingly. See the zf-oauth2 documentation for details.
Wilt
  • 41,477
  • 12
  • 152
  • 203
1

If you are on production mode and "config_cache_enabled" it's true, you need to delete files on data/cache folder

beerwin
  • 9,813
  • 6
  • 42
  • 57
pog8tor
  • 11
  • 2