} /* |-------------------------------------------------------------------------- | DEFAULT SCOPES |-------------------------------------------------------------------------- | | Supported scopes can be added to the plugin by modifying the wo_scopes. | Until further notice, the default scope is 'basic'. Plans are in place to | allow this scope to be adjusted. | */ $defaultScope = 'basic'; $supportedScopes = apply_filters('wo_scopes', null, 20); $memory = new OAuth2\Storage\Memory(array('default_scope' => $defaultScope, 'supported_scopes' => $supportedScopes)); $scopeUtil = new OAuth2\Scope($memory); $server->setScopeUtil($scopeUtil); /* |-------------------------------------------------------------------------- | TOKEN CATCH |-------------------------------------------------------------------------- | | The following code is ran when a request is made to the server using the | Authorization Code (implicit) Grant Type as well as request tokens | */ if ($method == 'token') { do_action('wo_before_token_method', array($_REQUEST)); $server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send(); exit; } /*
|-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ App::singleton('oauth2', function () { $storage = new OAuth2\Storage\Pdo(array('dsn' => 'mysql:dbname=insantani;host=localhost', 'username' => 'root', 'password' => '')); $server = new OAuth2\Server($storage); $server->addGrantType(new OAuth2\GrantType\ClientCredentials($storage)); $server->addGrantType(new OAuth2\GrantType\UserCredentials($storage)); $server->addGrantType(new OAuth2\GrantType\RefreshToken($storage)); $server->setScopeUtil(new OAuth2\Scope(array('supported_scopes' => array('read', 'write')))); return $server; }); Route::get('/', function () { return view('welcome'); }); Route::get('api/products', ['uses' => 'ProductController@products', 'middleware' => 'products']); Route::get('api/products/{id}', array('uses' => 'ProductController@productDetail', 'middleware' => 'products'))->where('id', '[0-9]+'); Route::get('api/products/{id}/picture', array('uses' => 'ProductController@showPicture', 'middleware' => 'products'))->where('id', '[0-9]+'); Route::get('api/feed', ['uses' => 'ArticleController@articles', 'middleware' => 'articles']); Route::get('api/search/product/{query}', array('uses' => 'SearchController@searchProduct', 'middleware' => 'products'))->where('query', '.+'); Route::get('api/search/tag/{query}', array('uses' => 'SearchController@searchTags', 'middleware' => 'articles'))->where('query', '.+'); Route::get('api/feed/article/{id}', array('uses' => 'ArticleController@articleDetail', 'middleware' => 'articles'))->where('id', '[0-9]+'); Route::get('api/feed/article/{id}/picture', array('uses' => 'ArticleController@showPicture', 'middleware' => 'articles'))->where('id', '[0-9]+'); Route::get('api/farmer/{id}/products', array('uses' => 'ProductController@relatedItems', 'middleware' => 'products'))->where('id', '.+'); Route::get('api/tag/{query}/results', array('uses' => 'TagController@tagResultDetail', 'middleware' => 'articles'))->where('query', '.+');