Skip to content

Commit aec2211

Browse files
cristiprgdopry
authored andcommitted
Add instructions in the test IDP for device authorization flow
This commit updates the test IDP fixture seed file with a new Device Flow OAuth application and updates the Readme with the corresponding instructions. The device flow does not really have a RP application, since the device itself is a RP, therefore used curl commands as an equivalent for PR.
1 parent 984fd72 commit aec2211

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

tests/app/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ These apps are for local end to end testing of DOT features. They were implement
44
local test environments. You should be able to start both and instance of the IDP and RP using the directions below, then test the
55
functionality of the IDP using the RP.
66

7+
The IDP seed data includes a Device Authorization OAuth application as well.
8+
79
## /tests/app/idp
810

911
This is an example IDP implementation for end to end testing. There are pre-configured fixtures which will work with the sample RP.
@@ -33,6 +35,36 @@ password: password
3335
python -Xutf8 ./manage.py dumpdata -e sessions -e admin.logentry -e auth.permission -e contenttypes.contenttype -e oauth2_provider.accesstoken -e oauth2_provider.refreshtoken -e oauth2_provider.idtoken --natural-foreign --natural-primary --indent 2 > fixtures/seed.json
3436
```
3537

38+
### Device Authorization example
39+
40+
For testing out the device authorization flow, we don't really need a RP, as the device itself
41+
is the "relying party". The seed data includes a Device Authorization Application, meaning
42+
you could directly start the device authorization flow using `curl`. In the real world, the device
43+
would be sending these request that we send here with `curl`.
44+
45+
_Note:_ you can find these `curl` commands in the Tutorial section of the documentation as well.
46+
47+
```sh
48+
# Initiate device authorization flow on the device; here we use the client_id
49+
# of the Device Authorization App from the seed data.
50+
curl --location 'http://127.0.0.1:8000/o/device-authorization/' \
51+
--header 'Content-Type: application/x-www-form-urlencoded' \
52+
--data-urlencode 'client_id=Qg8AaxKLs1c2W3PR70Sv5QxuSEREicKUlf83iGX3'
53+
```
54+
55+
Follow the `verification_uri` from the response (should be similar to http://127.0.0.1:8000/o/device"),
56+
enter the user code, approve, and then send another `curl` command to get the token.
57+
58+
```sh
59+
curl --location 'http://localhost:8000/o/token/' \
60+
--header 'Content-Type: application/x-www-form-urlencoded' \
61+
--data-urlencode 'device_code={the device code from the device-authorization response}' \
62+
--data-urlencode 'client_id=Qg8AaxKLs1c2W3PR70Sv5QxuSEREicKUlf83iGX3' \
63+
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:device_code'
64+
```
65+
66+
The response should include the access token.
67+
3668
## /test/app/rp
3769

3870
This is an example RP. It is a SPA built with Svelte.

tests/app/idp/fixtures/seed.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,26 @@
3434
"algorithm": "RS256",
3535
"allowed_origins": "http://localhost:5173\r\nhttp://127.0.0.1:5173"
3636
}
37+
},
38+
{
39+
"model": "oauth2_provider.application",
40+
"fields": {
41+
"client_id": "Qg8AaxKLs1c2W3PR70Sv5QxuSEREicKUlf83iGX3",
42+
"user": [
43+
"superuser"
44+
],
45+
"redirect_uris": "",
46+
"post_logout_redirect_uris": "",
47+
"client_type": "public",
48+
"authorization_grant_type": "urn:ietf:params:oauth:grant-type:device_code",
49+
"client_secret": "pbkdf2_sha256$870000$x1A7AKB9YMmNX7v2otXt1C$Yxucj9o/QlF16AxqN5LXo+Se0Sy3FO5x4Q35Lw1FGqM=",
50+
"hash_client_secret": true,
51+
"name": "Device Authorization App",
52+
"skip_authorization": false,
53+
"created": "2025-11-07T16:56:23.156Z",
54+
"updated": "2025-11-07T16:56:23.156Z",
55+
"algorithm": "",
56+
"allowed_origins": ""
57+
}
3758
}
3859
]

0 commit comments

Comments
 (0)