function obtainClientGrant(APITester $I) { $client = factory(App\Models\OAuthClient::class, 1)->create(); $grant = \App\Models\OAuthGrant::find('client_credentials'); $client->oauth_grants()->attach($grant); $scope = \App\Models\OAuthScope::find('content'); $client->oauth_scopes()->attach($scope); $I->wantTo('Send client credentials and receive an access token'); $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded'); $I->sendPOST('oauth/access_token', ['grant_type' => 'client_credentials', 'client_id' => $client->id, 'client_secret' => $client->secret, 'scope' => 'content']); $I->seeResponseCodeIs(200); $I->seeResponseIsJson(); $I->seeResponseMatchesJsonType(['access_token' => 'string']); }