@@ -214,19 +214,26 @@ jobs:
214
214
215
215
# Create a properly URL-encoded request
216
216
echo "Creating token exchange request..."
217
+ curl_data=$(cat << 'EOF'
218
+ client_id=$IDENTITY_FEDERATION_CLIENT_ID&\
219
+ subject_token=$OIDC_TOKEN&\
220
+ subject_token_type=urn:ietf:params:oauth:token-type:jwt&\
221
+ grant_type=urn:ietf:params:oauth:grant-type:token-exchange&\
222
+ scope=sql
223
+ EOF
224
+ )
225
+
226
+ # Substitute environment variables in the curl data
227
+ curl_data=$(eval echo "$curl_data")
217
228
218
229
# Print request details (except the token)
219
230
echo "Request URL: https://$DATABRICKS_HOST_FOR_TF/oidc/v1/token"
220
- echo "Request data: client_id=$IDENTITY_FEDERATION_CLIENT_ID& subject_token=REDACTED&subject_token_type=urn:ietf:params:oauth:token-type:jwt&grant_type=urn:ietf:params:oauth:grant-type:token-exchange&scope=sql "
231
+ echo "Request data: $(echo "$curl_data" | sed 's/subject_token=.*&/ subject_token=REDACTED&/') "
221
232
222
233
# Make the request with detailed info
223
234
echo "Sending request..."
224
235
response=$(curl -v -s -X POST "https://$DATABRICKS_HOST_FOR_TF/oidc/v1/token" \
225
- --data-urlencode "client_id=$IDENTITY_FEDERATION_CLIENT_ID" \
226
- --data-urlencode "subject_token=$OIDC_TOKEN" \
227
- --data-urlencode "subject_token_type=urn:ietf:params:oauth:token-type:jwt" \
228
- --data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
229
- --data-urlencode "scope=sql" \
236
+ --data-raw "$curl_data" \
230
237
-H "Content-Type: application/x-www-form-urlencoded" \
231
238
-H "Accept: application/json" \
232
239
2>&1)
@@ -239,6 +246,13 @@ jobs:
239
246
status_code=$(echo "$response" | grep -o "< HTTP/[0-9.]* [0-9]*" | grep -o "[0-9]*$" || echo "unknown")
240
247
echo "HTTP Status Code: $status_code"
241
248
249
+ # Try to extract and pretty-print the JSON response body if present
250
+ response_body=$(echo "$response" | sed -n -e '/^{/,/^}/p' || echo "")
251
+ if [ ! -z "$response_body" ]; then
252
+ echo "Response body (formatted):"
253
+ echo "$response_body" | python3 -m json.tool || echo "$response_body"
254
+ fi
255
+
242
256
# Don't fail the workflow if curl fails
243
257
exit 0
244
258
@@ -315,6 +329,18 @@ jobs:
315
329
print(f"Expected: {audience}")
316
330
print(f"Actual: {claims.get('aud')}")
317
331
332
+ # Enable more verbose HTTP debugging
333
+ import http.client as http_client
334
+ http_client.HTTPConnection.debuglevel = 1
335
+
336
+ # Log requests library debug info
337
+ import logging
338
+ logging.basicConfig()
339
+ logging.getLogger().setLevel(logging.DEBUG)
340
+ requests_log = logging.getLogger("requests.packages.urllib3")
341
+ requests_log.setLevel(logging.DEBUG)
342
+ requests_log.propagate = True
343
+
318
344
response = requests.post(url, data=data, headers=headers)
319
345
320
346
print(f"Status code: {response.status_code}")
0 commit comments