/** * Return the Random Access Token. * The access method should be POST. * The POST body should include 'client_id', 'client_secret', 'grant_type', 'code' and 'redirect_uri' used before. * The 'grant_type' must be 'authorization_code'; * The 'client_id' and 'client_secret' are registered in developer's center. * @return array AccessToken array if above parameters are valid, or error No. and message. */ public function run() { GrantType::checkGrantType(Yii::$app->request->post('grant_type'), GrantType::GRANT_TYPE_AUTHORIZATION_CODE); Client::checkClientSecret(Client::checkClientId(Yii::$app->request->post('client_id')), Yii::$app->request->post('client_secret')); AuthorizationCode::checkAuthorizationCode(Yii::$app->request->post('code'), Yii::$app->request->post('redirect_uri')); return AccessToken::createAccessToken(Yii::$app->request->post('client_id'), Yii::$app->request->post('code')); }