[ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->getUserModule() ->getAuthorizationChecker() ->isGrantedAsProducer($this->getUserCurrent()); } ] ], ], ]; } public function actionOauth(string $code) { $producerModule = $this->getProducerModule(); $curl = new curl\Curl(); $redirectUri = $producerModule->getSolver()->getConfig('tiller_redirect_uri'); $clientId = $producerModule->getSolver()->getConfig('tiller_client_id'); $clientSecret = $producerModule->getSolver()->getConfig('tiller_client_secret'); $url = "https://oauth.api.tiller.systems/oauth2/token?grant_type=authorization_code&redirect_uri=$redirectUri&client_id=$clientId&client_secret=$clientSecret&code=$code"; $response = $curl ->setHeaders(['Content-type' => 'application/x-www-form-urlencoded']) ->post($url); $datasResponse = json_decode($response); $accessToken = $datasResponse->access_token; $refreshToken = $datasResponse->refresh_token; $producer = $this->getProducerCurrent(); $producer->tiller_access_token = $accessToken; $producer->tiller_refresh_token = $refreshToken; $producer->save(); return $this->redirect(['distribution/index']); } }