@@ -822,7 +822,7 @@ def register_client(self, token: str, payload: dict):
822
822
)
823
823
return raise_error_from_response (data_raw , KeycloakPostError )
824
824
825
- def device (self ):
825
+ def device (self , scope : str = "" ):
826
826
"""Get device authorization grant.
827
827
828
828
The device endpoint is used to obtain a user code verification and user authentication.
@@ -837,11 +837,13 @@ def device(self):
837
837
https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow
838
838
https://github.com/keycloak/keycloak-community/blob/main/design/oauth2-device-authorization-grant.md#how-to-try-it
839
839
840
+ :param scope: Scope of authorization request, split with the blank space
841
+ :type scope: str
840
842
:returns: Device Authorization Response
841
843
:rtype: dict
842
844
"""
843
845
params_path = {"realm-name" : self .realm_name }
844
- payload = {"client_id" : self .client_id }
846
+ payload = {"client_id" : self .client_id , "scope" : scope }
845
847
846
848
payload = self ._add_secret_key (payload )
847
849
data_raw = self .connection .raw_post (URL_DEVICE .format (** params_path ), data = payload )
@@ -1464,7 +1466,7 @@ async def a_register_client(self, token: str, payload: dict):
1464
1466
)
1465
1467
return raise_error_from_response (data_raw , KeycloakPostError )
1466
1468
1467
- async def a_device (self ):
1469
+ async def a_device (self , scope : str = "" ):
1468
1470
"""Get device authorization grant asynchronously.
1469
1471
1470
1472
The device endpoint is used to obtain a user code verification and user authentication.
@@ -1479,11 +1481,13 @@ async def a_device(self):
1479
1481
https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow
1480
1482
https://github.com/keycloak/keycloak-community/blob/main/design/oauth2-device-authorization-grant.md#how-to-try-it
1481
1483
1484
+ :param scope: Scope of authorization request, split with the blank space
1485
+ :type scope: str
1482
1486
:returns: Device Authorization Response
1483
1487
:rtype: dict
1484
1488
"""
1485
1489
params_path = {"realm-name" : self .realm_name }
1486
- payload = {"client_id" : self .client_id }
1490
+ payload = {"client_id" : self .client_id , "scope" : scope }
1487
1491
1488
1492
payload = self ._add_secret_key (payload )
1489
1493
data_raw = await self .connection .a_raw_post (URL_DEVICE .format (** params_path ), data = payload )
0 commit comments