Skip to content

Commit 553795f

Browse files
Merge branch 'trial-testing:main' into main
2 parents 59a1a34 + 6afe93f commit 553795f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

.github/workflows/auth_try.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,24 @@ jobs:
5757
echo "$json_array" > files_payload.json
5858
echo "JSON_PAYLOAD_PATH=files_payload.json" >> $GITHUB_ENV
5959
60+
- name: 🔐 Authenticate via OIDC and get access token
61+
id: get_token
62+
run: |
63+
echo "Requesting OIDC token..."
64+
export ID_TOKEN=$(curl -s -X POST -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
65+
-H "Content-Type: application/json" \
66+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=${{ env.CLIENT_ID }}" | jq -r '.value')
67+
68+
echo "Exchanging OIDC token for access token..."
69+
access_token=$(curl -s -X POST https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/oauth2/v2.0/token \
70+
-d "client_id=${{ env.CLIENT_ID }}" \
71+
-d "grant_type=client_credentials" \
72+
-d "scope=api://${{ env.CLIENT_ID }}/.default" \
73+
-d "client_assertion=$ID_TOKEN" \
74+
-d "client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer" \
75+
| jq -r '.access_token')
76+
77+
echo "TOKEN=$access_token" >> $GITHUB_ENV
6078
6179
6280
# 3. Send a simple GET request to "/"

0 commit comments

Comments
 (0)