/** * Get consumer credentials (consumer_secret) * * @param string $consumerKey * @param string $type * @param string $enabled * @param array $options * Search criteria [ 'name', 'publisher', 'type', 'category', * 'website_url', 'email', 'description', 'callback_url' ] * @return array [ 'consumer_key', 'consumer_secret' ] */ public function getConsumerCredentials($consumerKey, $enabled = 1, $options = []) { $enabled = $enabled ? $enabled : 1; $options = array_merge([], $options); $builder = Consumer::where('consumer_key', $consumerKey)->where('enabled', $enabled); foreach (['name', 'publisher', 'type', 'category', 'website_url', 'email', 'description', 'callback_url'] as $field) { if (isset($options[$field])) { $builder->where($field, $options[$field]); } } $consumer = $builder->first(); if ($consumer) { return $consumer->getAttributes(); } return null; }
public function postAuthorize() { $isLogin = Input::has('authorize_login') ? true : false; if ($isLogin) { $this->login(); } else { // User confirm or deny $authorized = Input::has('confirm') ? true : false; $result = null; $state = null; if ($authorized) { try { $state = OAuthServer::authorizeVerify(); // If callback URL not 'oob' redirect will occur here $result = OAuthServer::authorizeFinish($authorized, Auth::user()->username); } catch (OAuthException $e) { return $this->error($e->getMessage()); } catch (\Exception $e) { \Log::error($e); return $this->error(trans('gponster/laravel-oauth-server::errors.authorize_fail')); } } $app = Consumer::where('consumer_key', $state['consumer_key'])->first(); // Display the result if callback URL is 'oob' $this->authorize(false, $app, $authorized, $result['verifier']); } }