$response1 = Invoke-WebRequest `
-Method Get `
-Uri "https://api.powerplatform.com/powerpages/environments/xxxxxx/websites?api-version=2022-03-01-preview" `
-Headers $apiHeaders
When I migrated this script to GitHub Actions, used an OIDC application user to log in, obtained a token, and then tried to access the same API, a 401 error occurred("Message": "Response status code does not indicate success: 401 (Unauthorized).")
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
allow-no-subscriptions: true
enable-AzPSSession: true
- name: Get API Token
shell: pwsh
run: |
$TOKEN = az account get-access-token `
--resource "https://api.powerplatform.com/" `
--query accessToken -o tsv
shell: pwsh
run: |
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
./activeWebsite.ps1 `

Report
All responses (
Answers (