Version 1.1 by messines on 2023/02/23 15:09

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
6 Add an attribute to the client JSON and update it
7
8
9 (% class="box" %)
10 (((
11 "attributes": {
12 "oauth2.device.authorization.grant.enabled": true
13 }
14 )))
15
16 == Request a code
17 ==
18
19 (% class="box" %)
20 (((
21 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']]; \
22
23 ~-~-header 'Content-Type: application/x-www-form-urlencoded' \
24
25 ~-~-data-urlencode 'client_id=your-client' \
26
27 ~-~-data-urlencode 'client_secret=your-secret' \   
28 )))
29
30 Secret is not require for public client.
31 \\The API will answer with a link
32
33 {{code language="json"}}
34 {
35 "device_code":"0zQm[...]e5h5kUvNYx0",
36 "user_code":"IWBR-DDY",
37 "verification_uri":"https://iam.ebrains.eu/auth/realms/hbp/device",
38 "verification_uri_complete":"https://iam.ebrains.eu/auth/realms/hbp/device?user_code=IWBR-DDYK",
39 "expires_in":600,
40 "interval":5
41 }
42 {{/code}}
43
44 == Visit the link to validate your code ==
45
46 Here you just need to visit the link in verification_uri_complete to validate your login and consent
47 \\
48
49 == Request your access token ==
50
51 Now you just need to request your access token, you need to enter the device_code provided in the first call above
52
53
54 (% class="box" %)
55 (((
56 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']]; \
57
58 ~-~-header 'Content-Type: application/x-www-form-urlencoded' \
59
60 ~-~-data-urlencode 'device_code=0zQm[...]e5h5kUvNYx0' \
61
62 ~-~-data-urlencode 'client_id=your-client' \
63 ~-~-data-urlencode 'client_secret=your-secret' \
64
65 ~-~-data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:device_code'
66 )))
67
68
69