Аналогично тому, как вы делаете это в основном приложении:
'user' => [
'identityClass' => 'common\models\User',
'loginUrl' => '/site/login',
'identityCookie' => [
'name' => '_identity-frontend',
],
],
Т.е. примерно так:
'modules' => [
'api1' => [
'class' => 'api\modules\Api1',
'components' => [
'user' => [
'identityClass' => 'common\models\Api1User',
'loginUrl' => '/site/login',
'identityCookie' => [
'name' => '_identity-api1',
],
],
]
],
'api2' => [
'class' => 'api\modules\Api2',
'components' => [
'user' => [
'identityClass' => 'common\models\Api2User',
'loginUrl' => '/site/login',
'identityCookie' => [
'name' => '_identity-api2',
],
],
]
],
]