请求提供GCP Datafusion HTTP插件对接Business Central的OAuth2配置示例
GCP Datafusion HTTP Properties 1.4.4插件OAuth2配置(Business Central数据提取)
问题背景
使用GCP Datafusion的HTTP Properties 1.4.4插件,通过OAuth2获取访问令牌提取Business Central数据时,持续收到错误:Error encountered while configuring the stage: 'Access token not found with Details: Response Code: '400', Error Message:'Bad Request'.'
对应的参考Curl命令:
获取授权令牌
curl --location --request GET 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header 'Cookie: fpc=AsrFv2JV-gJLll3s_Pw3GLBlfHdOAQAAAGok6t8OAAAA; stsservicecookie=estsfd; x-ms-gateway-slice=estsfd' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'client_id={client_id}' \ --data-urlencode 'client_secret={client_secret}' \ --data-urlencode 'scope=https://api.businesscentral.dynamics.com/.default'
使用令牌提取数据
curl --location --request GET 'https://api.businesscentral.dynamics.com/v2.0/{tenant}/CEE_Sandbox/api/rI/gL/v2.0/companies(company id)/**additional url parameters' \ --header 'Authorization: Bearer eyJ00E9IiwiYXBwaWQiOiI0**Full token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'grant_type=client_credentials' \ --data-urlencode 'client_id={client_id}' \ --data-urlencode 'client_secret={client_secret}' \ --data-urlencode 'scope=https://api.businesscentral.dynamics.com/.default'
配置示例
一、OAuth2令牌获取阶段(HTTP插件配置)
- 基础设置
- HTTP客户端类型:
Generic - HTTP方法:
POST(核心提示:微软OAuth2令牌端点仅支持POST,原Curl用GET是400错误的主要原因) - URL:
https://login.microsoftonline.com/{你的租户ID}/oauth2/v2.0/token
- HTTP客户端类型:
- 请求头
- 添加:
Content-Type: application/x-www-form-urlencoded - Cookie字段可选,测试阶段可忽略
- 添加:
- 请求体
- 请求体类型:
Form - 新增表单参数:
grant_type:client_credentialsclient_id:{你的客户端ID}client_secret:{你的客户端密钥}scope:https://api.businesscentral.dynamics.com/.default
- 请求体类型:
- 响应处理
- 设置响应格式为
JSON,确保插件能提取响应中的access_token字段,供后续数据提取阶段引用
- 设置响应格式为
二、Business Central数据提取阶段(HTTP插件配置)
- 基础设置
- HTTP方法:
GET - URL:
https://api.businesscentral.dynamics.com/v2.0/{你的租户ID}/CEE_Sandbox/api/rI/gL/v2.0/companies({公司ID})/**你的额外URL参数
- HTTP方法:
- 请求头
- 添加认证头:
Authorization: Bearer ${access_token}(${access_token}引用上一步获取的令牌值) - 根据API要求添加
Content-Type,通常为application/json
- 添加认证头:
- 数据解析
- 设置响应格式为
JSON,配置字段映射以匹配Business Central返回的数据结构
- 设置响应格式为
错误排查要点
- 确认令牌请求使用
POST方法:微软OAuth2 v2.0端点不接受GET请求,这是400错误的主要诱因 - 检查租户ID、客户端ID、客户端密钥是否完全匹配,无拼写或格式错误
- 验证
scope参数值准确,必须为https://api.businesscentral.dynamics.com/.default - 单独测试令牌请求(如用Postman),确认能返回有效
access_token
内容的提问来源于stack exchange,提问作者RaptorX
相关产品推荐
相关产品推荐

