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

Fastlane中仅用App Store Connect API Key认证时,如何通过Spaceship::ConnectAPI获取团队名

可以仅通过Spaceship::ConnectAPI获取团队名称

当然可以。在完成ConnectAPI的Token配置后,你可以通过Spaceship::ConnectAPI.user获取当前认证用户的信息,其中包含该用户所属的所有开发者团队数据,从中就能提取团队名称。

完整实现代码

# 你已完成的Token生成与设置代码
token = Spaceship::ConnectAPI::Token.create(
  key_id: key_id,
  issuer_id: issuer_id,
  filepath: File.absolute_path("#{file_name}")
)
Spaceship::ConnectAPI.token = token

# 获取团队名称
current_user = Spaceship::ConnectAPI.user
# 获取用户所属的第一个团队名称(如果有多个团队,可根据需求筛选)
team_name = current_user.teams.first.name

# 如果需要处理多团队场景,比如根据team_id筛选
target_team_id = "你的团队ID"
target_team = current_user.teams.find { |team| team.id == target_team_id }
target_team_name = target_team&.name

说明

  • current_user.teams返回的是一个包含所有关联团队的数组,每个团队对象包含name(团队名称)、id(团队ID)等属性
  • 如果你的API Key关联了多个开发者团队,建议通过指定team_id来精准获取目标团队名称,避免取错

内容的提问来源于stack exchange,提问作者Lescai Ionel

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.07 02:57:09