public function actionVerificationCode() { $code = Yii::$app->request->get('code'); $curl = new Curl(); $curl->post($this->module->OAuthUrl . '/token', ['grant_type' => 'authorization_code', 'code' => $code, 'client_id' => $this->module->appId, 'client_secret' => $this->module->appPassword]); $token = $curl->response->access_token; $settings = YmSettings::findOne(['id' => 1]); $settings->token = $token; $settings->save(); $this->redirect('/yandex-metrika/default/index'); }
public function init() { parent::init(); $settings = YmSettings::findOne(['id' => 1]); $this->OAuthToken = $settings->token; }