web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Azure Login (OIDC) po...
Power Pages
Suggested Answer

Azure Login (OIDC) powerplatform API 401 error

(0) ShareShare
ReportReport
Posted on by 10
When my PowerShell script runs locally, I use【 az login】 to log in to my account via a pop-up window, and then obtain a token to access the following powerplatform API without any issues

    $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).")
 
      - name: Azure Login (OIDC)
        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
          "API_TOKEN=$TOKEN" | Out-File -FilePath $Env:GITHUB_ENV -Append
      - name: Enable Website
        shell: pwsh
        run: |
          Set-StrictMode -Version Latest
          $ErrorActionPreference = 'Stop'
          
          ./activeWebsite.ps1 `
 
Any guidance or best practices would be appreciated.
Categories:
I have the same question (0)
  • Suggested answer
    11manish Profile Picture
    1,422 on at
    Your GitHub Actions setup is correct, but:
    The service principal you’re using does not have access to Power Platform environments.
    To fix:
    • Add the app as an Application User in Dataverse
    • Assign appropriate security role
    • Then reuse your token

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 61

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 40 Most Valuable Professional

#3
11manish Profile Picture

11manish 30

Last 30 days Overall leaderboard