Version 2.1 by messines on 2023/02/23 15:10

Show last authors
1 == Update your client to enable Device Flow ==
2
3 Not available through the UI yet, use the [[lab notebook>>https://lab.ch.ebrains.eu/hub/user-redirect/lab/tree/shared/Collaboratory%20Community%20Apps/Managing%20an%20OpenID%20Connect%20client%20-%20V2.ipynb]]
4
5 Add an attribute to the client JSON and update it
6
7
8 (% class="box" %)
9 (((
10 "attributes": {
11 "oauth2.device.authorization.grant.enabled": true
12 }
13 )))
14
15 == Request a code ==
16
17 (% class="box" %)
18 (((
19 curl ~-~-location ~-~-request POST '[[https:~~/~~/iam.ebrains.eu/auth/realms/hbp/protocol/openid-connect/auth/device'>>url:https://iam.ebrains.eu/auth/realms/hbp/protocol/openid-connect/auth/device']]; \
20
21 ~-~-header 'Content-Type: application/x-www-form-urlencoded' \
22
23 ~-~-data-urlencode 'client_id=your-client' \
24
25 ~-~-data-urlencode 'client_secret=your-secret' \   
26 )))
27
28 Secret is not require for public client.
29 \\The API will answer with a link
30
31 {{code language="json"}}
32 {
33 "device_code":"0zQm[...]e5h5kUvNYx0",
34 "user_code":"IWBR-DDY",
35 "verification_uri":"https://iam.ebrains.eu/auth/realms/hbp/device",
36 "verification_uri_complete":"https://iam.ebrains.eu/auth/realms/hbp/device?user_code=IWBR-DDYK",
37 "expires_in":600,
38 "interval":5
39 }
40 {{/code}}
41
42 == Visit the link to validate your code ==
43
44 Here you just need to visit the link in verification_uri_complete to validate your login and consent
45
46 == Request your access token ==
47
48 Now you just need to request your access token, you need to enter the device_code provided in the first call above
49
50 (% class="box" %)
51 (((
52 curl ~-~-location ~-~-request POST '[[https:~~/~~/iam.ebrains.eu/auth/realms/hbp/protocol/openid-connect/token'>>url:https://iam.ebrains.eu/auth/realms/hbp/protocol/openid-connect/token']]; \
53
54 ~-~-header 'Content-Type: application/x-www-form-urlencoded' \
55
56 ~-~-data-urlencode 'device_code=0zQm[...]e5h5kUvNYx0' \
57
58 ~-~-data-urlencode 'client_id=your-client' \
59 ~-~-data-urlencode 'client_secret=your-secret' \
60
61 ~-~-data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:device_code'
62 )))
63
64
65