从 Azure Functions 请求图表 API
Request to Graph API from Azure Functions
我试图了解 Azure Functions 对图 API 的请求是如何工作的。
从我的 Azure Functions 的应用程序服务中,我生成了 Active Directoy 应用程序,并从那里添加了 "API Permissions" 以便能够对图形 API 发出请求。
我的疑惑如下:
1- 当我访问我的 AAD 应用程序 (____.azurewebsites.net/.auth/me) 的端点时,我可以使用它 return 发出请求的访问令牌吗图API?我做了一些测试,但 return 出现以下错误:
CompactToken 解析失败,错误代码:80049217
2- 我还尝试向端点发出请求:https://login.microsoftonline.com/[TENANT-ID]/oauth2/v2.0/token 以便它应该 return 一个访问令牌来向 Graph 的 API 发出请求。但我收到下一个错误:
请求正文必须包含以下参数:'grant_type'
为此尝试,我正在使用 Postman/Insomnia。但是我不太确定如何继续尝试。
预先致谢
1- When I access the endpoint of my AAD App
(____.azurewebsites.net/.auth/me), could I use the access token that
it returns to make the request to the Graph API?
是的,你可以。您需要在 authsettings 下的 additionalLoginParams 添加 ["resource=https://graph.microsoft.com"]
。详情请参阅 this blog。
2- I have also tried to make a request to the endpoint:
https://login.microsoftonline.com/[TENANT-ID]/oauth2/v2.0/token so
that it should return an access token to make the request to the API
of Graph. But I am getting the next error: The request body must
contain the following parameter: 'grant_type'
要调用此端点,您将需要一些参数,请参阅this article了解更多详细信息。
另外就是API权限、委托权限和A两种申请权限。您应该使用委派权限而不是应用程序权限。
参考:
Difference between Azure App Registration -‘Delegated’ and ‘Application’ Permission
我试图了解 Azure Functions 对图 API 的请求是如何工作的。
从我的 Azure Functions 的应用程序服务中,我生成了 Active Directoy 应用程序,并从那里添加了 "API Permissions" 以便能够对图形 API 发出请求。
我的疑惑如下:
1- 当我访问我的 AAD 应用程序 (____.azurewebsites.net/.auth/me) 的端点时,我可以使用它 return 发出请求的访问令牌吗图API?我做了一些测试,但 return 出现以下错误: CompactToken 解析失败,错误代码:80049217
2- 我还尝试向端点发出请求:https://login.microsoftonline.com/[TENANT-ID]/oauth2/v2.0/token 以便它应该 return 一个访问令牌来向 Graph 的 API 发出请求。但我收到下一个错误: 请求正文必须包含以下参数:'grant_type'
为此尝试,我正在使用 Postman/Insomnia。但是我不太确定如何继续尝试。
预先致谢
1- When I access the endpoint of my AAD App (____.azurewebsites.net/.auth/me), could I use the access token that it returns to make the request to the Graph API?
是的,你可以。您需要在 authsettings 下的 additionalLoginParams 添加 ["resource=https://graph.microsoft.com"]
。详情请参阅 this blog。
2- I have also tried to make a request to the endpoint: https://login.microsoftonline.com/[TENANT-ID]/oauth2/v2.0/token so that it should return an access token to make the request to the API of Graph. But I am getting the next error: The request body must contain the following parameter: 'grant_type'
要调用此端点,您将需要一些参数,请参阅this article了解更多详细信息。
另外就是API权限、委托权限和A两种申请权限。您应该使用委派权限而不是应用程序权限。
参考:
Difference between Azure App Registration -‘Delegated’ and ‘Application’ Permission