Skip to content

Commit 8156456

Browse files
committed
Added new client_credential login
1 parent 9f1cbfd commit 8156456

File tree

4 files changed

+56
-24
lines changed

4 files changed

+56
-24
lines changed

CustomApi/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ $apiInstance = new WebMI\KeycloakApiClient\CustomApi\Api\CustomApi(
5555
new GuzzleHttp\Client()
5656
);
5757
$realm = 'realm_example'; // string | realm name (not id!)
58+
$authorization = 'authorization_example'; // string | Basic Auth with client_id and client_secret encoded in base64
59+
$grant_type = 'refresh_token'; // string | Grant Type
5860
$username = 'username_example'; // string | Username
5961
$password = 'password_example'; // string | User Password
6062
$client_id = 'client_id_example'; // string | Client id
61-
$grant_type = 'grant_type_example'; // string | Grant Type
6263
$refresh_token = 'refresh_token_example'; // string | Refresh Token
6364

6465
try {
65-
$result = $apiInstance->realmsRealmProtocolOpenidConnectTokenPost($realm, $username, $password, $client_id, $grant_type, $refresh_token);
66+
$result = $apiInstance->realmsRealmProtocolOpenidConnectTokenPost($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token);
6667
print_r($result);
6768
} catch (Exception $e) {
6869
echo 'Exception when calling CustomApi->realmsRealmProtocolOpenidConnectTokenPost: ', $e->getMessage(), PHP_EOL;

CustomApi/docs/Api/CustomApi.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All URIs are relative to http://localhost, except if the operation defines anoth
1010
## `realmsRealmProtocolOpenidConnectTokenPost()`
1111

1212
```php
13-
realmsRealmProtocolOpenidConnectTokenPost($realm, $username, $password, $client_id, $grant_type, $refresh_token): \WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost200Response
13+
realmsRealmProtocolOpenidConnectTokenPost($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token): \WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost200Response
1414
```
1515

1616
Oidc Login
@@ -31,14 +31,15 @@ $apiInstance = new WebMI\KeycloakApiClient\CustomApi\Api\CustomApi(
3131
new GuzzleHttp\Client()
3232
);
3333
$realm = 'realm_example'; // string | realm name (not id!)
34+
$authorization = 'authorization_example'; // string | Basic Auth with client_id and client_secret encoded in base64
35+
$grant_type = 'refresh_token'; // string | Grant Type
3436
$username = 'username_example'; // string | Username
3537
$password = 'password_example'; // string | User Password
3638
$client_id = 'client_id_example'; // string | Client id
37-
$grant_type = 'grant_type_example'; // string | Grant Type
3839
$refresh_token = 'refresh_token_example'; // string | Refresh Token
3940

4041
try {
41-
$result = $apiInstance->realmsRealmProtocolOpenidConnectTokenPost($realm, $username, $password, $client_id, $grant_type, $refresh_token);
42+
$result = $apiInstance->realmsRealmProtocolOpenidConnectTokenPost($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token);
4243
print_r($result);
4344
} catch (Exception $e) {
4445
echo 'Exception when calling CustomApi->realmsRealmProtocolOpenidConnectTokenPost: ', $e->getMessage(), PHP_EOL;
@@ -50,10 +51,11 @@ try {
5051
| Name | Type | Description | Notes |
5152
| ------------- | ------------- | ------------- | ------------- |
5253
| **realm** | **string**| realm name (not id!) | |
54+
| **authorization** | **string**| Basic Auth with client_id and client_secret encoded in base64 | [optional] |
55+
| **grant_type** | **string**| Grant Type | [optional] [default to 'refresh_token'] |
5356
| **username** | **string**| Username | [optional] |
5457
| **password** | **string**| User Password | [optional] |
5558
| **client_id** | **string**| Client id | [optional] |
56-
| **grant_type** | **string**| Grant Type | [optional] |
5759
| **refresh_token** | **string**| Refresh Token | [optional] |
5860

5961
### Return type

CustomApi/lib/Api/CustomApi.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,21 @@ public function getConfig()
128128
* Oidc Login
129129
*
130130
* @param string $realm realm name (not id!) (required)
131+
* @param string|null $authorization Basic Auth with client_id and client_secret encoded in base64 (optional)
132+
* @param string|null $grant_type Grant Type (optional, default to 'refresh_token')
131133
* @param string|null $username Username (optional)
132134
* @param string|null $password User Password (optional)
133135
* @param string|null $client_id Client id (optional)
134-
* @param string|null $grant_type Grant Type (optional)
135136
* @param string|null $refresh_token Refresh Token (optional)
136137
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'] to see the possible values for this operation
137138
*
138139
* @throws \WebMI\KeycloakApiClient\CustomApi\ApiException on non-2xx response or if the response body is not in the expected format
139140
* @throws \InvalidArgumentException
140141
* @return \WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost200Response|\WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost400Response|\WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost400Response
141142
*/
142-
public function realmsRealmProtocolOpenidConnectTokenPost($realm, $username = null, $password = null, $client_id = null, $grant_type = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
143+
public function realmsRealmProtocolOpenidConnectTokenPost($realm, $authorization = null, $grant_type = 'refresh_token', $username = null, $password = null, $client_id = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
143144
{
144-
list($response) = $this->realmsRealmProtocolOpenidConnectTokenPostWithHttpInfo($realm, $username, $password, $client_id, $grant_type, $refresh_token, $contentType);
145+
list($response) = $this->realmsRealmProtocolOpenidConnectTokenPostWithHttpInfo($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token, $contentType);
145146
return $response;
146147
}
147148

@@ -151,20 +152,21 @@ public function realmsRealmProtocolOpenidConnectTokenPost($realm, $username = nu
151152
* Oidc Login
152153
*
153154
* @param string $realm realm name (not id!) (required)
155+
* @param string|null $authorization Basic Auth with client_id and client_secret encoded in base64 (optional)
156+
* @param string|null $grant_type Grant Type (optional, default to 'refresh_token')
154157
* @param string|null $username Username (optional)
155158
* @param string|null $password User Password (optional)
156159
* @param string|null $client_id Client id (optional)
157-
* @param string|null $grant_type Grant Type (optional)
158160
* @param string|null $refresh_token Refresh Token (optional)
159161
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'] to see the possible values for this operation
160162
*
161163
* @throws \WebMI\KeycloakApiClient\CustomApi\ApiException on non-2xx response or if the response body is not in the expected format
162164
* @throws \InvalidArgumentException
163165
* @return array of \WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost200Response|\WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost400Response|\WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost400Response, HTTP status code, HTTP response headers (array of strings)
164166
*/
165-
public function realmsRealmProtocolOpenidConnectTokenPostWithHttpInfo($realm, $username = null, $password = null, $client_id = null, $grant_type = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
167+
public function realmsRealmProtocolOpenidConnectTokenPostWithHttpInfo($realm, $authorization = null, $grant_type = 'refresh_token', $username = null, $password = null, $client_id = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
166168
{
167-
$request = $this->realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $username, $password, $client_id, $grant_type, $refresh_token, $contentType);
169+
$request = $this->realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token, $contentType);
168170

169171
try {
170172
$options = $this->createHttpClientOption();
@@ -351,19 +353,20 @@ public function realmsRealmProtocolOpenidConnectTokenPostWithHttpInfo($realm, $u
351353
* Oidc Login
352354
*
353355
* @param string $realm realm name (not id!) (required)
356+
* @param string|null $authorization Basic Auth with client_id and client_secret encoded in base64 (optional)
357+
* @param string|null $grant_type Grant Type (optional, default to 'refresh_token')
354358
* @param string|null $username Username (optional)
355359
* @param string|null $password User Password (optional)
356360
* @param string|null $client_id Client id (optional)
357-
* @param string|null $grant_type Grant Type (optional)
358361
* @param string|null $refresh_token Refresh Token (optional)
359362
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'] to see the possible values for this operation
360363
*
361364
* @throws \InvalidArgumentException
362365
* @return \GuzzleHttp\Promise\PromiseInterface
363366
*/
364-
public function realmsRealmProtocolOpenidConnectTokenPostAsync($realm, $username = null, $password = null, $client_id = null, $grant_type = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
367+
public function realmsRealmProtocolOpenidConnectTokenPostAsync($realm, $authorization = null, $grant_type = 'refresh_token', $username = null, $password = null, $client_id = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
365368
{
366-
return $this->realmsRealmProtocolOpenidConnectTokenPostAsyncWithHttpInfo($realm, $username, $password, $client_id, $grant_type, $refresh_token, $contentType)
369+
return $this->realmsRealmProtocolOpenidConnectTokenPostAsyncWithHttpInfo($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token, $contentType)
367370
->then(
368371
function ($response) {
369372
return $response[0];
@@ -377,20 +380,21 @@ function ($response) {
377380
* Oidc Login
378381
*
379382
* @param string $realm realm name (not id!) (required)
383+
* @param string|null $authorization Basic Auth with client_id and client_secret encoded in base64 (optional)
384+
* @param string|null $grant_type Grant Type (optional, default to 'refresh_token')
380385
* @param string|null $username Username (optional)
381386
* @param string|null $password User Password (optional)
382387
* @param string|null $client_id Client id (optional)
383-
* @param string|null $grant_type Grant Type (optional)
384388
* @param string|null $refresh_token Refresh Token (optional)
385389
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'] to see the possible values for this operation
386390
*
387391
* @throws \InvalidArgumentException
388392
* @return \GuzzleHttp\Promise\PromiseInterface
389393
*/
390-
public function realmsRealmProtocolOpenidConnectTokenPostAsyncWithHttpInfo($realm, $username = null, $password = null, $client_id = null, $grant_type = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
394+
public function realmsRealmProtocolOpenidConnectTokenPostAsyncWithHttpInfo($realm, $authorization = null, $grant_type = 'refresh_token', $username = null, $password = null, $client_id = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
391395
{
392396
$returnType = '\WebMI\KeycloakApiClient\CustomApi\Model\RealmsRealmProtocolOpenidConnectTokenPost200Response';
393-
$request = $this->realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $username, $password, $client_id, $grant_type, $refresh_token, $contentType);
397+
$request = $this->realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $authorization, $grant_type, $username, $password, $client_id, $refresh_token, $contentType);
394398

395399
return $this->client
396400
->sendAsync($request, $this->createHttpClientOption())
@@ -432,17 +436,18 @@ function ($exception) {
432436
* Create request for operation 'realmsRealmProtocolOpenidConnectTokenPost'
433437
*
434438
* @param string $realm realm name (not id!) (required)
439+
* @param string|null $authorization Basic Auth with client_id and client_secret encoded in base64 (optional)
440+
* @param string|null $grant_type Grant Type (optional, default to 'refresh_token')
435441
* @param string|null $username Username (optional)
436442
* @param string|null $password User Password (optional)
437443
* @param string|null $client_id Client id (optional)
438-
* @param string|null $grant_type Grant Type (optional)
439444
* @param string|null $refresh_token Refresh Token (optional)
440445
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'] to see the possible values for this operation
441446
*
442447
* @throws \InvalidArgumentException
443448
* @return \GuzzleHttp\Psr7\Request
444449
*/
445-
public function realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $username = null, $password = null, $client_id = null, $grant_type = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
450+
public function realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $authorization = null, $grant_type = 'refresh_token', $username = null, $password = null, $client_id = null, $refresh_token = null, string $contentType = self::contentTypes['realmsRealmProtocolOpenidConnectTokenPost'][0])
446451
{
447452

448453
// verify the required parameter 'realm' is set
@@ -458,6 +463,7 @@ public function realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $userna
458463

459464

460465

466+
461467
$resourcePath = '/realms/{realm}/protocol/openid-connect/token';
462468
$formParams = [];
463469
$queryParams = [];
@@ -466,6 +472,10 @@ public function realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $userna
466472
$multipart = false;
467473

468474

475+
// header params
476+
if ($authorization !== null) {
477+
$headerParams['Authorization'] = ObjectSerializer::toHeaderValue($authorization);
478+
}
469479

470480
// path params
471481
if ($realm !== null) {
@@ -476,6 +486,10 @@ public function realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $userna
476486
);
477487
}
478488

489+
// form params
490+
if ($grant_type !== null) {
491+
$formParams = array_merge($formParams, ObjectSerializer::toFormValue('grant_type', $grant_type));
492+
}
479493
// form params
480494
if ($username !== null) {
481495
$formParams = array_merge($formParams, ObjectSerializer::toFormValue('username', $username));
@@ -489,10 +503,6 @@ public function realmsRealmProtocolOpenidConnectTokenPostRequest($realm, $userna
489503
$formParams = array_merge($formParams, ObjectSerializer::toFormValue('client_id', $client_id));
490504
}
491505
// form params
492-
if ($grant_type !== null) {
493-
$formParams = array_merge($formParams, ObjectSerializer::toFormValue('grant_type', $grant_type));
494-
}
495-
// form params
496506
if ($refresh_token !== null) {
497507
$formParams = array_merge($formParams, ObjectSerializer::toFormValue('refresh_token', $refresh_token));
498508
}

custom.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ paths:
1414
required: true
1515
schema:
1616
type: string
17+
- name: Authorization
18+
in: header
19+
description: Basic Auth with client_id and client_secret encoded in base64
20+
required: false
21+
schema:
22+
type: string
1723
post:
1824
tags:
1925
- Custom
@@ -24,6 +30,7 @@ paths:
2430
application/x-www-form-urlencoded:
2531
schema:
2632
oneOf:
33+
- $ref: '#/components/schemas/ClientCredentialsRequest'
2734
- $ref: '#/components/schemas/UsernamePasswordRequest'
2835
- $ref: '#/components/schemas/RefreshRequest'
2936
responses:
@@ -100,6 +107,16 @@ paths:
100107

101108
components:
102109
schemas:
110+
ClientCredentialsRequest:
111+
type: object
112+
properties:
113+
grant_type:
114+
type: string
115+
description: Grant Type
116+
example: client_credentials
117+
default: client_credentials
118+
required:
119+
- grant_type
103120
UsernamePasswordRequest:
104121
type: object
105122
properties:
@@ -119,6 +136,7 @@ components:
119136
type: string
120137
description: Grant Type
121138
example: password
139+
default: password
122140
required:
123141
- username
124142
- password
@@ -135,6 +153,7 @@ components:
135153
type: string
136154
description: Grant Type
137155
example: refresh_token
156+
default: refresh_token
138157
refresh_token:
139158
type: string
140159
description: Refresh Token

0 commit comments

Comments
 (0)