/** * Create a service object given a ServiceFactory object * * @param \OAuth\ServiceFactory $factory * @return \OAuth\Common\Service\ServiceInterface */ public function createService(ServiceFactory $factory) { $appId = $this->config->get('auth.community.appid'); $appSecret = $this->config->get('auth.community.secret'); // Get the callback url /** @var Url $callbackUrl */ $callbackUrl = $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/community/callback/']); if ($callbackUrl->getHost() == '') { $callbackUrl = $callbackUrl->setHost($this->request->getHost()); $callbackUrl = $callbackUrl->setScheme($this->request->getScheme()); } // Create a credential object with our ID, Secret, and callback url $credentials = new Credentials($appId, $appSecret, (string) $callbackUrl); // Create a new session storage object and pass it the active session $storage = new SymfonySession($this->session, false); // Create the service using the oauth service factory return $factory->createService('community', $credentials, $storage); }
/** * Create a service object given a ServiceFactory object * * @return \OAuth\Common\Service\ServiceInterface */ public function createService() { $appId = $this->config->get('auth.twitter.appid'); $appSecret = $this->config->get('auth.twitter.secret'); $verifyPeer = $this->config->get('app.curl.verifyPeer'); /** @var ServiceFactory $factory */ $factory = $this->app->make('oauth/factory/service', array(CURLOPT_SSL_VERIFYPEER => $verifyPeer)); // Get the callback url $callbackUrl = $this->urlResolver->resolve(['/ccm/system/authentication/oauth2/twitter/callback/']); if ($callbackUrl->getHost() == '') { $callbackUrl = $callbackUrl->setHost($this->request->getHost()); $callbackUrl = $callbackUrl->setScheme($this->request->getScheme()); } // Create a credential object with our ID, Secret, and callback url $credentials = new Credentials($appId, $appSecret, (string) $callbackUrl); // Create a new session storage object and pass it the active session $storage = new SymfonySession($this->session, false); // Create the service using the oauth service factory return $factory->createService('twitter', $credentials, $storage); }