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 / Audience validation fa...
Power Pages
Unanswered

Audience validation failed for OAuth 2.0 implicit grant flow within portal

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have integrated OAuth 2.0 implicit grant flow within portal following this below document:

https://docs.microsoft.com/en-us/powerapps/maker/portals/oauth-implicit-grant-flow#register-client-id-for-implicit-grant-flow

 

but getting following error in my api while debugging:

 

{"xxxxxx: Audience validation failed. Audiences: ''. Did not match: validationParameters.ValidAudience: 'xxxxxxxxxxxxxxxxxx' or validationParameters.ValidAudiences: 'null'."}

 

I have added these site settings in my portal:

Connector/ImplicitGrantFlowEnabled to True

ImplicitGrantFlow/TokenExpirationTime to 3600

ImplicitGrantFlow/RegisteredClientId to Client ID (from azure AD app)

ImplicitGrantFlow/{ClientId}/RedirectUri to my portal page

 

I have integrated this following Token Endpoint JavaScript code in portal page:

https://github.com/microsoft/PowerApps-Samples/blob/master/portals/TokenEndpoint.js

 

and my azure hosted API code here:

https://github.com/microsoft/PowerApps-Samples/tree/master/portals/ExternalWebApiConsumingPortalOAuthTokenSample

 

What I have done wrong for which the above error is generating?

Categories:
I have the same question (0)
  • justinburch Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    It's been awhile since I've implemented this. At what point in the sample code is the error being thrown?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi Justin,

    Thanks your reply. I have deployed C# sample into azure hosting. Trying to access whoami api url from portal providing client id in both of js and c# platform. But getting the mentioned above error while debugging in audience validation and the result is 401 unauthorized access to that api.

     

    in this site setting: ImplicitGrantFlow/{ClientId}/RedirectUri 

    do I need to replace the full {ClientId} with azure ad client id?

     

    I think something is wrong in my setting which need to identify. 

     

  • justinburch Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

    Yes, you would need to replace the ClientID with the actual client ID. Have you tried this?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello Justin,

    Thank you for your reply.

     

    Yes I added the client id there but the issue was since my token doesn't contain any aud value so I need to set validateAudience false in c# code. It works now.

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
DP_Prabh Profile Picture

DP_Prabh 51

#2
rezarizvii Profile Picture

rezarizvii 35

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 35 Most Valuable Professional

Last 30 days Overall leaderboard