Azure App Service中两个启用身份验证的FastAPI应用调用API时出现403 Forbidden错误
Azure App Service中两个启用身份验证的FastAPI应用调用API时出现403 Forbidden错误
大家好,我最近碰到一个难题,想请教下社区的大佬们:我在Azure App Service上部署了两个FastAPI应用,都开启了App Service Authentication,但当尝试从其中一个应用调用另一个的API时,始终收到403 Forbidden错误,折腾了好久都没解决,下面是详细信息:
Environment
Platform: Azure App Service Number of Applications: 2 Authentication: App Service Authentication enabled on both apps Framework: FastAPI
Problem Description
我有两个部署在Azure App Service上的FastAPI应用,都启用了App Service Authentication。当尝试从一个应用调用另一个的API时,持续收到403 Forbidden错误。
身份验证配置截图:

App_service_A配置截图:

App_service_B配置截图:

Code Snippet (Calling the API of App Service A from App Service B)
下面是我从App Service B调用App Service A API的代码片段:
# Example API call code from azure.identity import DefaultAzureCredential credential = DefaultAzureCredential() import requests token = credential.get_token("api://{client_id_app_service_A}/max**") api_url = "https://*.azurewebsites.net/api/task" headers = { 'Authorization': f'Bearer {token.token}' } response = requests.get(api_url, headers=headers) print("============================Response==============================", response) print(response.json)
备注:内容来源于stack exchange,提问作者Kai Pham
相关产品推荐
相关产品推荐

