public function OAuth2ServerTest::testClientCredentialsGrantType in OAuth2 Server 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/OAuth2ServerTest.php \Drupal\Tests\oauth2_server\Functional\OAuth2ServerTest::testClientCredentialsGrantType()
Tests the "Client credentials" grant type.
File
- tests/
src/ Functional/ OAuth2ServerTest.php, line 252
Class
- OAuth2ServerTest
- The OAuth2 Server admin test case.
Namespace
Drupal\Tests\oauth2_server\FunctionalCode
public function testClientCredentialsGrantType() {
$user = $this
->drupalCreateUser([
'use oauth2 server',
]);
$this
->drupalLogin($user);
$token_url = $this
->buildUrl(new Url('oauth2_server.token'));
$data = [
'grant_type' => 'client_credentials',
];
$response = $this
->httpPostRequest($token_url, $data);
$this
->assertEqual($response
->getStatusCode(), 200, 'The token request completed successfully');
$payload = json_decode($response
->getBody());
$this
->assertTokenResponse($payload, FALSE);
}