You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/oauth2/README.md
+51-1Lines changed: 51 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,39 @@ export STATE="your-state"
102
102
go run ./scripts/oauth2/oauth2-test-server.go
103
103
```
104
104
105
+
###`test-device-flow.sh`
106
+
107
+
Tests the OAuth2 Device Authorization Flow (RFC 8628) using the golang.org/x/oauth2 library. This flow is designed for devices that either lack a web browser or have limited input capabilities.
108
+
109
+
Usage:
110
+
111
+
```bash
112
+
# First set up an app
113
+
eval$(./scripts/oauth2/setup-test-app.sh)
114
+
115
+
# Run the device flow test
116
+
./scripts/oauth2/test-device-flow.sh
117
+
```
118
+
119
+
Features:
120
+
121
+
- Implements the complete device authorization flow
122
+
- Uses the`/x/oauth2` library for OAuth2 operations
123
+
- Displays user code and verification URL
124
+
- Automatically polls for token completion
125
+
- Tests the access token with an API call
126
+
- Colored output for better readability
127
+
128
+
###`oauth2-device-flow.go`
129
+
130
+
A Go program that implements the OAuth2 device authorization flow. Used internally by`test-device-flow.sh` but can also be run standalone:
131
+
132
+
```bash
133
+
export CLIENT_ID="your-client-id"
134
+
export CLIENT_SECRET="your-client-secret"
135
+
go run ./scripts/oauth2/oauth2-device-flow.go
136
+
```
137
+
105
138
##Example Workflow
106
139
107
140
1.**Run automated tests:**
@@ -126,7 +159,23 @@ go run ./scripts/oauth2/oauth2-test-server.go
126
159
./scripts/oauth2/cleanup-test-app.sh
127
160
```
128
161
129
-
3.**Generate PKCE for custom testing:**
162
+
3.**Device authorization flow testing:**
163
+
164
+
```bash
165
+
# Create app
166
+
eval$(./scripts/oauth2/setup-test-app.sh)
167
+
168
+
# Run the device flow test
169
+
./scripts/oauth2/test-device-flow.sh
170
+
# - Shows device code and verification URL
171
+
# - Polls for authorization completion
172
+
# - Tests access token
173
+
174
+
# Clean up when done
175
+
./scripts/oauth2/cleanup-test-app.sh
176
+
```
177
+
178
+
4.**Generate PKCE for custom testing:**
130
179
131
180
```bash
132
181
./scripts/oauth2/generate-pkce.sh
@@ -147,4 +196,5 @@ All scripts respect these environment variables: