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 24
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
    3,333 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
  • Suggested answer
    CU08010919-1 Profile Picture
    24 on at

    I can access other APIs under https://api.powerplatform.com using an OIDC user, but I can't access the APIs related to powerpages. I guess powerpages  APIs might not be accessible to OIDC users

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 38

#2
Valantis Profile Picture

Valantis 36

#3
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard