You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flask OAuth API集成ServiceNow时出现access_token缺失错误求助

Flask OAuth API与ServiceNow集成报错:Missing parameters: access_token

问题详情

在集成Flask OAuth API与ServiceNow时触发错误:

OAuth flow failed. Verify the configurations and try again. Error detail:invalid_request, Missing parameters: access_token

操作流程:

  • 登录ServiceNow,进入System OAuth -> Application Registry -> Connect to a third-party OAuth Provider配置第三方OAuth服务
  • 调用Access Token URL获取令牌,该接口仅返回JSON格式的token和expiresin字段

根因分析

ServiceNow的OAuth客户端遵循OAuth 2.0标准,默认期望令牌接口返回**access_token**字段作为令牌值,而你的Flask API返回的是token,字段名不匹配导致ServiceNow无法识别有效令牌,进而抛出参数缺失错误。

解决方案

方案1:修改Flask API的返回字段(推荐)

调整Access Token接口的返回结构,将字段名改为OAuth标准命名:

{
  "access_token": "your_actual_token_string",
  "expires_in": 3600
}

注:expires_in是标准过期时间字段名,替换原expiresin也能避免后续可能的时间解析问题。

方案2:在ServiceNow中配置字段映射(无法修改API时使用)

如果无法调整Flask API的返回结构,可在ServiceNow中自定义字段映射:

  1. 进入对应第三方OAuth提供者的配置页面
  2. 找到关联的OAuth Entity Profile(或类似配置项)
  3. 在Token Parameters Mapping区域添加映射规则:
    • 将ServiceNow侧的access_token映射到API返回的token
    • 将ServiceNow侧的expires_in映射到API返回的expiresin

方案3:验证请求参数完整性

确认ServiceNow配置的请求参数(如grant_type、client_id、client_secret等)与Flask API的要求完全匹配,避免因参数错误导致API返回异常结构。

内容的提问来源于stack exchange,提问作者Karthik K Kashi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 08:50:25