Error Forbidden 403 – Azure Function with Easy Auth through AAD

the case here, i need to call azure function from outside the azure from web app through azure AAD-Oauth2.
The easy authentication has been configured for azure function.
There are 2 app Registration created:

  1. the first one is api-app reg for Azure function which is created during configuring the Easy Authentication for azure function
  2. the second one is client-app reg and adapt the necessary application permission

The problem is, if i try to call azure function through postman,
i create firstly get a token through client credentials (with client secret und client id of second app reg):
“https://login.microsoftonline.com/xxxxx-tenant-id-xxxxx/oauth2/v2.0/token”
then afterthat i try to call the azure function with bearer token, then i have got this error
Forbidden 403 – “You do not have permission to view this directory or page.”
Azure Function url: https://webapp01.azurewebsites.net/api/HttpTrigger1?name=azure01

i think the issue, if i call the function, then request is not going to the function and the azure blocked the request for any reason. maybe, the token is not right!

That is the content of token:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"aud": "api://50a-xx-xxx-xxx",
"iss": "https://sts.windows.net/xxx-xxx-xx-xxxx/",
"iat": 1725464551,
"nbf": 1725464551,
"exp": 1725468451,
"aio": "E2dgYCjjk5Sw22y9K0dUIxxxxxxx",
"appid": "xx-xx-xxx-xxx",
"appidacr": "1",
"idp": "https://sts.windows.net/xx-xxxx-xxx-xxxx/",
"oid": "fbxx-xxx-xxx-xx",
"rh": "0.Aa8AYuDbAiI46UqAc7EpL6NmODqlrFAahSRLgOxxxxxxxxx",
"roles": [
"FunctionReader"
],
"sub": "fbxx-xxx-xx-xx",
"tid": "02xx-xx-x-xxx",
"uti": "0kwCap10NES-sH0PXmr2AA",
"ver": "1.0"
}
</code>
<code>{ "aud": "api://50a-xx-xxx-xxx", "iss": "https://sts.windows.net/xxx-xxx-xx-xxxx/", "iat": 1725464551, "nbf": 1725464551, "exp": 1725468451, "aio": "E2dgYCjjk5Sw22y9K0dUIxxxxxxx", "appid": "xx-xx-xxx-xxx", "appidacr": "1", "idp": "https://sts.windows.net/xx-xxxx-xxx-xxxx/", "oid": "fbxx-xxx-xxx-xx", "rh": "0.Aa8AYuDbAiI46UqAc7EpL6NmODqlrFAahSRLgOxxxxxxxxx", "roles": [ "FunctionReader" ], "sub": "fbxx-xxx-xx-xx", "tid": "02xx-xx-x-xxx", "uti": "0kwCap10NES-sH0PXmr2AA", "ver": "1.0" } </code>
{
  "aud": "api://50a-xx-xxx-xxx",
  "iss": "https://sts.windows.net/xxx-xxx-xx-xxxx/",
  "iat": 1725464551,
  "nbf": 1725464551,
  "exp": 1725468451,
  "aio": "E2dgYCjjk5Sw22y9K0dUIxxxxxxx",
  "appid": "xx-xx-xxx-xxx",
  "appidacr": "1",
  "idp": "https://sts.windows.net/xx-xxxx-xxx-xxxx/",
  "oid": "fbxx-xxx-xxx-xx",
  "rh": "0.Aa8AYuDbAiI46UqAc7EpL6NmODqlrFAahSRLgOxxxxxxxxx",
  "roles": [
    "FunctionReader"
  ],
  "sub": "fbxx-xxx-xx-xx",
  "tid": "02xx-xx-x-xxx",
  "uti": "0kwCap10NES-sH0PXmr2AA",
  "ver": "1.0"
}

I tried the token with ver 1.0 and 2.0 but it the same problem
Is there any idea to get a solution for this problem or workaround?

Thank you

I tried here token with v1 and v2 but not working
i used “ID Token”
i tried “iss”: “https://sts.windows.net/xxx-xxx-xx-xxxx/v2.0 with v2.0 and without v2.0

I have added the client id of second app in Authentication of function app.

Also add the function app permission and redirect URIs in the second client app.

Then, you can generate the token using given url.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>https://login.microsoftonline.com/{tenant_Id}/oauth2/v2.0/authorize
?client_id={client_Id of second app}
&response_type=token
&redirect_uri=https://jwt.ms
&scope=api://{client_id of function app}/.default
&response_mode=fragment
&state=12345
</code>
<code>https://login.microsoftonline.com/{tenant_Id}/oauth2/v2.0/authorize ?client_id={client_Id of second app} &response_type=token &redirect_uri=https://jwt.ms &scope=api://{client_id of function app}/.default &response_mode=fragment &state=12345 </code>
https://login.microsoftonline.com/{tenant_Id}/oauth2/v2.0/authorize
?client_id={client_Id of second app}
&response_type=token
&redirect_uri=https://jwt.ms
&scope=api://{client_id of function app}/.default
&response_mode=fragment
&state=12345

Use the generated token while invoking function.

By doing so, I am able to access the function url.

Recognized by Microsoft Azure Collective

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật